@codama/spec 1.6.0-rc.4 → 1.6.0-rc.5
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 +84 -0
- package/dist/api.browser.cjs +18 -1
- package/dist/api.browser.cjs.map +1 -1
- package/dist/api.browser.mjs +18 -2
- package/dist/api.browser.mjs.map +1 -1
- package/dist/api.node.cjs +18 -1
- package/dist/api.node.cjs.map +1 -1
- package/dist/api.node.mjs +18 -2
- package/dist/api.node.mjs.map +1 -1
- package/dist/api.react-native.mjs +18 -2
- package/dist/api.react-native.mjs.map +1 -1
- package/dist/index.browser.cjs +161 -145
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs +161 -145
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.cjs +161 -145
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +161 -145
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.react-native.mjs +161 -145
- package/dist/index.react-native.mjs.map +1 -1
- package/dist/types/api/defineNestedUnion.d.ts +1 -1
- package/dist/types/api/defineUnion.d.ts +1 -1
- package/dist/types/api/index.d.ts +1 -1
- package/dist/types/api/primitives.d.ts +7 -1
- package/dist/types/api/primitives.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +15 -6
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/api/validate.d.ts.map +1 -1
- package/dist/types/v1/nestedUnions.d.ts +1 -1
- package/dist/types/v1/nodes/contextualValueNodes/ContextualValueNode.d.ts +2 -2
- package/dist/types/v1/nodes/pdaSeedNodes/PdaSeedNode.d.ts +1 -1
- package/dist/types/v1/nodes/typeNodes/TypeNode.d.ts +4 -4
- package/dist/types/v1/nodes/valueNodes/ValueNode.d.ts +4 -4
- package/dist/v1.browser.cjs +161 -145
- package/dist/v1.browser.cjs.map +1 -1
- package/dist/v1.browser.mjs +161 -145
- package/dist/v1.browser.mjs.map +1 -1
- package/dist/v1.node.cjs +161 -145
- package/dist/v1.node.cjs.map +1 -1
- package/dist/v1.node.mjs +161 -145
- package/dist/v1.node.mjs.map +1 -1
- package/dist/v1.react-native.mjs +161 -145
- package/dist/v1.react-native.mjs.map +1 -1
- package/package.json +45 -31
package/dist/api.node.cjs
CHANGED
|
@@ -99,6 +99,9 @@ function normaliseMember(input) {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
// src/api/primitives.ts
|
|
102
|
+
function address() {
|
|
103
|
+
return Object.freeze({ kind: "address" });
|
|
104
|
+
}
|
|
102
105
|
function string() {
|
|
103
106
|
return Object.freeze({ kind: "string" });
|
|
104
107
|
}
|
|
@@ -172,6 +175,8 @@ function docs() {
|
|
|
172
175
|
}
|
|
173
176
|
|
|
174
177
|
// src/api/validate.ts
|
|
178
|
+
var CAMEL_CASE_REGEX = /^[a-z][A-Za-z0-9]*$/;
|
|
179
|
+
var NODE_KIND_REGEX = /^[a-z][A-Za-z0-9]*Node$/;
|
|
175
180
|
function validate(spec) {
|
|
176
181
|
const errors = [];
|
|
177
182
|
const allNodes = [];
|
|
@@ -209,7 +214,7 @@ function validate(spec) {
|
|
|
209
214
|
seenCategories.add(c.name);
|
|
210
215
|
}
|
|
211
216
|
for (const n of allNodes) {
|
|
212
|
-
if (
|
|
217
|
+
if (!NODE_KIND_REGEX.test(n.kind)) {
|
|
213
218
|
errors.push(`Node kind "${n.kind}" does not match the camelCase ...Node naming convention.`);
|
|
214
219
|
}
|
|
215
220
|
const seenAttrs = /* @__PURE__ */ new Set();
|
|
@@ -225,6 +230,9 @@ function validate(spec) {
|
|
|
225
230
|
}
|
|
226
231
|
}
|
|
227
232
|
for (const u of allUnions) {
|
|
233
|
+
if (!CAMEL_CASE_REGEX.test(u.name)) {
|
|
234
|
+
errors.push(`Union "${u.name}" does not match the camelCase naming convention.`);
|
|
235
|
+
}
|
|
228
236
|
if (u.members.length === 0) {
|
|
229
237
|
errors.push(`Union "${u.name}" has no members.`);
|
|
230
238
|
}
|
|
@@ -243,7 +251,15 @@ function validate(spec) {
|
|
|
243
251
|
}
|
|
244
252
|
}
|
|
245
253
|
}
|
|
254
|
+
for (const e of allEnumerations) {
|
|
255
|
+
if (!CAMEL_CASE_REGEX.test(e.name)) {
|
|
256
|
+
errors.push(`Enumeration "${e.name}" does not match the camelCase naming convention.`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
246
259
|
for (const nu of allNestedUnions) {
|
|
260
|
+
if (!CAMEL_CASE_REGEX.test(nu.name)) {
|
|
261
|
+
errors.push(`Nested union "${nu.name}" does not match the camelCase naming convention.`);
|
|
262
|
+
}
|
|
247
263
|
if (nu.wrappers.length === 0) {
|
|
248
264
|
errors.push(`Nested union "${nu.name}" has no wrappers.`);
|
|
249
265
|
}
|
|
@@ -312,6 +328,7 @@ function isChildAttribute(type) {
|
|
|
312
328
|
}
|
|
313
329
|
}
|
|
314
330
|
|
|
331
|
+
exports.address = address;
|
|
315
332
|
exports.array = array;
|
|
316
333
|
exports.attribute = attribute;
|
|
317
334
|
exports.boolean = boolean;
|
package/dist/api.node.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/attribute.ts","../src/api/compounds.ts","../src/api/defineCategory.ts","../src/api/defineEnumeration.ts","../src/api/defineNestedUnion.ts","../src/api/defineNode.ts","../src/api/defineUnion.ts","../src/api/primitives.ts","../src/api/semanticAliases.ts","../src/api/validate.ts"],"names":[],"mappings":";;;AAoBO,SAAS,SAAA,CAAU,IAAA,EAAc,IAAA,EAAgB,OAAA,GAA4B,EAAC,EAAkB;AACnG,EAAA,OAAO,OAAO,MAAA,CAAO;AAAA,IACjB,IAAA;AAAA,IACA,IAAA;AAAA,IACA,GAAI,OAAA,CAAQ,QAAA,GAAW,EAAE,QAAA,EAAU,IAAA,KAAkB,EAAC;AAAA,IACtD,GAAI,OAAA,CAAQ,IAAA,KAAS,MAAA,GAAY,EAAE,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,CAAC,GAAG,OAAA,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AA;AAEnB","file":"api.node.cjs","sourcesContent":["/**\n * Attribute factories — produce frozen `AttributeSpec` values directly.\n *\n * Every attribute of a node MUST be constructed via one of these helpers.\n * The returned value IS the encoded form; `defineNode` consumes them as-is.\n */\n\nimport type { AttributeSpec, TypeExpr } from './types';\n\nexport interface AttributeOptions {\n /** Free-form prose paragraphs describing this attribute. */\n readonly docs?: readonly string[];\n /** When `true`, the attribute may be absent in encoded values. */\n readonly optional?: boolean;\n}\n\n/**\n * Declare an attribute. The default is a required attribute; pass\n * `{ optional: true }` (or use `optionalAttribute`) to mark it optional.\n */\nexport function attribute(name: string, type: TypeExpr, options: AttributeOptions = {}): AttributeSpec {\n return Object.freeze({\n name,\n type,\n ...(options.optional ? { optional: true as const } : {}),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\n/**\n * Sugar for `attribute(name, type, { optional: true, ...rest })` — the most\n * common attribute shape after required ones.\n */\nexport function optionalAttribute(\n name: string,\n type: TypeExpr,\n options: Omit<AttributeOptions, 'optional'> = {},\n): AttributeSpec {\n return attribute(name, type, { ...options, optional: true });\n}\n","/**\n * Compound type-expression constructors — wrap or combine other type\n * expressions. Returned values are frozen.\n *\n * Optionality is intentionally NOT a compound: it's an attribute-level\n * concern, expressed via `optionalAttribute(...)` or\n * `attribute(..., { optional: true })`.\n */\n\nimport type { TypeExpr } from './types';\n\n/** An array (homogeneous list) of `inner`. */\nexport function array(inner: TypeExpr): TypeExpr {\n return Object.freeze({ kind: 'array' as const, of: inner });\n}\n\n/**\n * A heterogeneous fixed-length tuple. Each positional slot has its own type.\n *\n * Tuples use `items` (plural) rather than `of` to signal cardinality > 1.\n */\nexport function tuple(...items: TypeExpr[]): TypeExpr {\n return Object.freeze({ kind: 'tuple' as const, items: Object.freeze([...items]) });\n}\n","/**\n * `defineCategory(name, options)` — group a coherent set of nodes,\n * unions, enumerations, and nested unions under a single name.\n *\n * Categories double as a filing hint for codegen targets that organise\n * output by category (e.g. the TypeScript node-types generator emits\n * each category into its own subdirectory). Category names are arbitrary\n * strings; the spec doesn't constrain them.\n */\n\nimport type { CategorySpec, EnumerationSpec, NestedUnionSpec, NodeSpec, UnionSpec } from './types';\n\nexport interface DefineCategoryOptions {\n readonly docs?: readonly string[];\n readonly nodes?: readonly NodeSpec[];\n readonly unions?: readonly UnionSpec[];\n readonly enumerations?: readonly EnumerationSpec[];\n readonly nestedUnions?: readonly NestedUnionSpec[];\n}\n\nexport function defineCategory(name: string, options: DefineCategoryOptions = {}): CategorySpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n nodes: Object.freeze([...(options.nodes ?? [])]),\n unions: Object.freeze([...(options.unions ?? [])]),\n enumerations: Object.freeze([...(options.enumerations ?? [])]),\n nestedUnions: Object.freeze([...(options.nestedUnions ?? [])]),\n });\n}\n","/**\n * `defineEnumeration(name, options)` — declares a named enumeration.\n *\n * Codegen emits a string-literal union (TS), a real `enum` (Rust), a class\n * (Python), etc., according to each language's idiom. Per-variant docs are\n * carried through to language-native member documentation.\n */\n\nimport type { EnumerationSpec, EnumerationVariantSpec } from './types';\n\nexport interface VariantOptions {\n readonly docs?: readonly string[];\n}\n\n/** Construct a single enumeration variant. */\nexport function variant(name: string, options: VariantOptions = {}): EnumerationVariantSpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\nexport interface DefineEnumerationOptions {\n readonly docs?: readonly string[];\n readonly variants: readonly EnumerationVariantSpec[];\n}\n\nexport function defineEnumeration(name: string, options: DefineEnumerationOptions): EnumerationSpec {\n if (options.variants.length === 0) {\n throw new Error(`defineEnumeration(\"${name}\"): variants must be non-empty`);\n }\n const seen = new Set<string>();\n for (const v of options.variants) {\n if (seen.has(v.name)) {\n throw new Error(`defineEnumeration(\"${name}\"): duplicate variant \"${v.name}\"`);\n }\n seen.add(v.name);\n }\n return Object.freeze({\n name,\n variants: Object.freeze([...options.variants]),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n","/**\n * `defineNestedUnion(name, options)` — declares a recursive type alias,\n * e.g. `NestedTypeNode<T>`.\n *\n * Codegen renders one alternative per wrapper kind, plus the base case:\n *\n * ```ts\n * type Alias<T extends Base> = Wrapper1<Alias<T>> | Wrapper2<Alias<T>> | … | T;\n * ```\n *\n * Use the `nestedUnion(alias, innerKind)` `TypeExpr` helper to reference\n * an instance of this alias from an attribute.\n */\n\nimport type { NestedUnionSpec, TypeExpr } from './types';\n\nexport interface DefineNestedUnionOptions {\n readonly docs?: readonly string[];\n /**\n * The base type the recursion bottoms out in. Codegen renders this\n * as the alias's type-parameter constraint and as the final union arm.\n */\n readonly base: TypeExpr;\n /**\n * Node kinds that act as wrappers in the recursion. Each must be a\n * node whose attribute structure can wrap another `NestedUnion<T>`.\n */\n readonly wrappers: readonly string[];\n}\n\nexport function defineNestedUnion(name: string, options: DefineNestedUnionOptions): NestedUnionSpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n base: options.base,\n wrappers: Object.freeze([...options.wrappers]),\n });\n}\n","/**\n * `defineNode(kind, options)` — declares a single Codama node.\n *\n * The `kind` string is the discriminator value. By convention it ends in\n * `Node` and uses camelCase (e.g. `accountNode`, `arrayTypeNode`).\n *\n * `attributes` is an ordered array of values produced by `attribute(...)` or\n * `optionalAttribute(...)`. Order is preserved in the encoded spec and, by\n * extension, in generated code. The `kind: literal(<kind>)` discriminator\n * is implicit and is NOT declared by authors.\n *\n * The data-vs-children distinction is derived at codegen time from each\n * attribute's type tree (see `isChildAttribute` in `validate.ts`); the\n * meta-model itself just stores a flat list.\n */\n\nimport type { AttributeSpec, NodeSpec } from './types';\n\nexport interface DefineNodeOptions {\n /** Free-form prose paragraphs describing this node. */\n readonly docs?: readonly string[];\n /**\n * Attributes of the node, in declaration order. Construct each entry\n * via `attribute(...)` or `optionalAttribute(...)`.\n */\n readonly attributes: readonly AttributeSpec[];\n /** Free-form examples (shape defined per spec major version). */\n readonly examples?: readonly unknown[];\n}\n\nexport function defineNode(kind: string, options: DefineNodeOptions): NodeSpec {\n return Object.freeze({\n kind,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n attributes: Object.freeze([...options.attributes]),\n examples: Object.freeze([...(options.examples ?? [])]),\n });\n}\n","/**\n * `defineUnion(name, options)` — declares a named union of nodes.\n *\n * Members can be:\n * - a node kind string (e.g. `'arrayTypeNode'`), or\n * - a `node(...)` / `union(...)` reference (a `TypeExpr` produced by\n * `primitives.ts`).\n *\n * Nested unions are preserved structurally in the encoded spec rather than\n * flattened. This serves two purposes:\n * - DRY authoring (`union('StandaloneTypeNode')` instead of repeating 23\n * kind names).\n * - A signal to the Rust codegen to emit `From`/`Into` trait impls between\n * the parent union and each nested union.\n */\n\nimport type { TypeExpr, UnionMember, UnionSpec } from './types';\n\nexport type UnionMemberInput = TypeExpr | string;\n\nexport interface DefineUnionOptions {\n readonly docs?: readonly string[];\n readonly members: readonly UnionMemberInput[];\n}\n\nexport function defineUnion(name: string, options: DefineUnionOptions): UnionSpec {\n const normalised: UnionMember[] = options.members.map(normaliseMember);\n return Object.freeze({\n name,\n members: Object.freeze(normalised),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\nfunction normaliseMember(input: UnionMemberInput): UnionMember {\n if (typeof input === 'string') {\n // Bare strings are treated as node kinds (the most common case).\n return Object.freeze({ kind: 'node' as const, name: input });\n }\n if (input.kind === 'node') return Object.freeze({ kind: 'node' as const, name: input.name });\n if (input.kind === 'union') return Object.freeze({ kind: 'union' as const, name: input.name });\n throw new Error(\n `defineUnion: members must be node kind strings, node(...) or union(...) references; got ${JSON.stringify(input)}`,\n );\n}\n","/**\n * Type-expression primitives — the leaves of any attribute's type tree.\n *\n * Each function returns a frozen `TypeExpr` value. The encoded spec stores\n * those objects verbatim; codegen targets read them and emit native types.\n */\n\nimport type { FloatWidth, IntegerWidth, LiteralValue, StringConstraint, TypeExpr } from './types';\n\n// Strings.\n\n/** Plain UTF-8 string. */\nexport function string(): TypeExpr {\n return Object.freeze({ kind: 'string' as const });\n}\n\n/**\n * A string that must be a valid IDL identifier (stored canonically in\n * camelCase). Renderers may convert to other casings at output time.\n */\nexport function stringIdentifier(): TypeExpr {\n return Object.freeze({ kind: 'string' as const, constraint: 'identifier' as const });\n}\n\n/** A string that must be a valid version (e.g. `\"1.6.0\"`). */\nexport function stringVersion(): TypeExpr {\n return Object.freeze({ kind: 'string' as const, constraint: 'version' as const });\n}\n\n/**\n * The version string of the surrounding Codama spec. Treat as a brand on\n * top of `stringVersion()` — the value is always pinned to the spec\n * version of the IDL document. Codegen targets typically emit a literal\n * type or a constant.\n */\nexport function codamaVersion(): TypeExpr {\n return Object.freeze({ kind: 'codamaVersion' as const });\n}\n\n// Integers (explicit bit widths — no machine-dependent usize/isize).\n\nconst integer = (width: IntegerWidth): TypeExpr => Object.freeze({ kind: 'integer' as const, width });\n\nexport const u8 = (): TypeExpr => integer('u8');\nexport const u16 = (): TypeExpr => integer('u16');\nexport const u32 = (): TypeExpr => integer('u32');\nexport const u64 = (): TypeExpr => integer('u64');\nexport const u128 = (): TypeExpr => integer('u128');\nexport const i8 = (): TypeExpr => integer('i8');\nexport const i16 = (): TypeExpr => integer('i16');\nexport const i32 = (): TypeExpr => integer('i32');\nexport const i64 = (): TypeExpr => integer('i64');\nexport const i128 = (): TypeExpr => integer('i128');\n\n// Floats.\n\nconst float = (width: FloatWidth): TypeExpr => Object.freeze({ kind: 'float' as const, width });\n\nexport const f32 = (): TypeExpr => float('f32');\nexport const f64 = (): TypeExpr => float('f64');\n\n// Booleans and literals.\n\nexport function boolean(): TypeExpr {\n return Object.freeze({ kind: 'boolean' as const });\n}\n\n/** A single fixed value of a primitive type. */\nexport function literal(value: LiteralValue): TypeExpr {\n return Object.freeze({ kind: 'literal' as const, value });\n}\n\n/**\n * A heterogeneous union of literal values — for sum types like\n * `boolean | 'either'` that don't fit a string-only enumeration.\n *\n * Codegen targets render this as the appropriate language idiom (a literal\n * union in TS, a tagged enum with custom serde in Rust, etc.).\n */\nexport function literalUnion(...values: LiteralValue[]): TypeExpr {\n if (values.length === 0) {\n throw new Error('literalUnion: at least one value required');\n }\n const seen = new Set<LiteralValue>();\n for (const v of values) {\n if (seen.has(v)) {\n throw new Error(`literalUnion: duplicate value ${JSON.stringify(v)}`);\n }\n seen.add(v);\n }\n return Object.freeze({ kind: 'literalUnion' as const, values: Object.freeze([...values]) });\n}\n\n// Named references.\n\n/** Reference to a named enumeration declared via `defineEnumeration`. */\nexport function enumeration(name: string): TypeExpr {\n return Object.freeze({ kind: 'enumeration' as const, name });\n}\n\n/** Reference to a named node declared via `defineNode`. */\nexport function node(name: string): TypeExpr {\n return Object.freeze({ kind: 'node' as const, name });\n}\n\n/** Reference to a named union declared via `defineUnion`. */\nexport function union(name: string): TypeExpr {\n return Object.freeze({ kind: 'union' as const, name });\n}\n\n/**\n * Reference to a named node, wrapped by a named recursive `NestedUnion`\n * alias. `alias` selects which `NestedUnion` declared via\n * `defineNestedUnion` the wrapping uses (e.g. `'NestedTypeNode'`); `name`\n * is the inner node kind.\n *\n * Renderers emit `<alias><<innerInterface>>` and an import for the alias\n * file.\n */\nexport function nestedUnion(alias: string, name: string): TypeExpr {\n return Object.freeze({ kind: 'nestedUnion' as const, alias, name });\n}\n\n// Re-exports for type ergonomics.\nexport type { FloatWidth, IntegerWidth, LiteralValue, StringConstraint, TypeExpr };\n","/**\n * Author-side semantic aliases.\n *\n * Most aliases desugar at call time so the encoded spec only ever shows\n * the underlying primitive (e.g. `{ kind: \"integer\", width: \"u64\" }` for\n * both `u64()` and `byteSize()`). Each language's codegen may further\n * specialise rendering for these widths (e.g. Rust may render `u64` as\n * `usize` for byte-size fields if it wants). Those are codegen policies\n * — not spec content.\n *\n * `docs()` is the exception: it returns its own `'docs'` `TypeExpr` kind\n * so the documentation intent survives in the encoded spec rather than\n * collapsing to `array(string())`.\n */\n\nimport { i64, u32, u64 } from './primitives';\nimport type { TypeExpr } from './types';\n\n/** Number of bytes; non-negative. Encoded as `u64`. */\nexport function byteSize(): TypeExpr {\n return u64();\n}\n\n/** Signed byte offset. Encoded as `i64`. */\nexport function byteOffset(): TypeExpr {\n return i64();\n}\n\n/** Count of items in a collection; non-negative. Encoded as `u32`. */\nexport function count(): TypeExpr {\n return u32();\n}\n\n/**\n * Documentation for a node — semantically a list of paragraph strings,\n * but rendered per language at codegen time (e.g. `Array<string>` in\n * TypeScript, `Vec<String>` in Rust). Returns its own `'docs'` kind so\n * the intent isn't lost in the encoded spec.\n */\nexport function docs(): TypeExpr {\n return Object.freeze({ kind: 'docs' as const });\n}\n","/**\n * Self-consistency validation for an assembled spec.\n *\n * Returns an array of human-readable error strings. An empty array means\n * the spec is internally coherent — every reference resolves, no\n * duplicate names, naming conventions hold.\n */\n\nimport type { EnumerationSpec, NestedUnionSpec, NodeSpec, Spec, TypeExpr, UnionSpec } from './types';\n\ntype RegistryKind = 'enumeration' | 'nestedUnion' | 'node' | 'union';\n\nexport function validate(spec: Spec): string[] {\n const errors: string[] = [];\n\n const allNodes: NodeSpec[] = [];\n const allUnions: UnionSpec[] = [];\n const allEnumerations: EnumerationSpec[] = [];\n const allNestedUnions: NestedUnionSpec[] = [];\n for (const c of spec.categories) {\n allNodes.push(...c.nodes);\n allUnions.push(...c.unions);\n allEnumerations.push(...c.enumerations);\n allNestedUnions.push(...c.nestedUnions);\n }\n\n const nodeKinds = new Set(allNodes.map(n => n.kind));\n const unionNames = new Set(allUnions.map(u => u.name));\n const enumerationNames = new Set(allEnumerations.map(e => e.name));\n const nestedUnionNames = new Set(allNestedUnions.map(nu => nu.name));\n\n // Single-pass name-collision check across nodes, unions, enumerations,\n // and nested unions. One error per offending name.\n const registrations = new Map<string, RegistryKind[]>();\n const record = (name: string, kind: RegistryKind): void => {\n const list = registrations.get(name);\n if (list) list.push(kind);\n else registrations.set(name, [kind]);\n };\n for (const n of allNodes) record(n.kind, 'node');\n for (const u of allUnions) record(u.name, 'union');\n for (const e of allEnumerations) record(e.name, 'enumeration');\n for (const nu of allNestedUnions) record(nu.name, 'nestedUnion');\n\n for (const [name, kinds] of registrations) {\n if (kinds.length > 1) errors.push(formatCollisionError(name, kinds));\n }\n\n // Duplicate category names.\n const seenCategories = new Set<string>();\n for (const c of spec.categories) {\n if (seenCategories.has(c.name)) {\n errors.push(`Category \"${c.name}\" is declared more than once.`);\n }\n seenCategories.add(c.name);\n }\n\n // Per-node validation.\n for (const n of allNodes) {\n if (!/^[a-z][A-Za-z0-9]*Node$/.test(n.kind)) {\n errors.push(`Node kind \"${n.kind}\" does not match the camelCase ...Node naming convention.`);\n }\n const seenAttrs = new Set<string>();\n for (const a of n.attributes) {\n if (seenAttrs.has(a.name)) {\n errors.push(`Node \"${n.kind}\" declares attribute \"${a.name}\" more than once.`);\n }\n seenAttrs.add(a.name);\n walkTypeExpr(a.type, expr =>\n checkRef(expr, n.kind, a.name, errors, nodeKinds, unionNames, enumerationNames, nestedUnionNames),\n );\n }\n }\n\n // Union member resolution.\n for (const u of allUnions) {\n if (u.members.length === 0) {\n errors.push(`Union \"${u.name}\" has no members.`);\n }\n const seenMembers = new Set<string>();\n for (const m of u.members) {\n const key = `${m.kind}:${m.name}`;\n if (seenMembers.has(key)) {\n errors.push(`Union \"${u.name}\" lists member ${key} more than once.`);\n }\n seenMembers.add(key);\n if (m.kind === 'node' && !nodeKinds.has(m.name)) {\n errors.push(`Union \"${u.name}\" references undefined node \"${m.name}\".`);\n }\n if (m.kind === 'union' && !unionNames.has(m.name)) {\n errors.push(`Union \"${u.name}\" references undefined union \"${m.name}\".`);\n }\n }\n }\n\n // Nested-union wrapper sanity.\n for (const nu of allNestedUnions) {\n if (nu.wrappers.length === 0) {\n errors.push(`Nested union \"${nu.name}\" has no wrappers.`);\n }\n for (const w of nu.wrappers) {\n if (!nodeKinds.has(w)) {\n errors.push(`Nested union \"${nu.name}\" wrapper \"${w}\" is not a defined node.`);\n }\n }\n }\n\n return errors;\n}\n\nfunction formatCollisionError(name: string, kinds: RegistryKind[]): string {\n const counts = new Map<RegistryKind, number>();\n for (const k of kinds) counts.set(k, (counts.get(k) ?? 0) + 1);\n const breakdown = [...counts.entries()]\n .sort((a, b) => a[0].localeCompare(b[0]))\n .map(([k, n]) => `${n} ${k}${n > 1 ? 's' : ''}`)\n .join(', ');\n return `Name \"${name}\" is registered ${kinds.length} times (${breakdown}); names must be unique across nodes, unions, enumerations, and nested unions.`;\n}\n\nfunction walkTypeExpr(expr: TypeExpr, visit: (expr: TypeExpr) => void): void {\n visit(expr);\n if (expr.kind === 'array') {\n walkTypeExpr(expr.of, visit);\n } else if (expr.kind === 'tuple') {\n for (const item of expr.items) walkTypeExpr(item, visit);\n }\n}\n\nfunction checkRef(\n expr: TypeExpr,\n nodeKind: string,\n attrName: string,\n errors: string[],\n nodeKinds: Set<string>,\n unionNames: Set<string>,\n enumerationNames: Set<string>,\n nestedUnionNames: Set<string>,\n): void {\n const where = `Node \"${nodeKind}\", attribute \"${attrName}\":`;\n switch (expr.kind) {\n case 'node':\n if (!nodeKinds.has(expr.name)) {\n errors.push(`${where} references undefined node \"${expr.name}\".`);\n }\n break;\n case 'union':\n if (!unionNames.has(expr.name)) {\n errors.push(`${where} references undefined union \"${expr.name}\".`);\n }\n break;\n case 'enumeration':\n if (!enumerationNames.has(expr.name)) {\n errors.push(`${where} references undefined enumeration \"${expr.name}\".`);\n }\n break;\n case 'nestedUnion':\n if (!nodeKinds.has(expr.name)) {\n errors.push(`${where} nestedUnion references undefined node \"${expr.name}\".`);\n }\n if (!nestedUnionNames.has(expr.alias)) {\n errors.push(`${where} nestedUnion references undefined alias \"${expr.alias}\".`);\n }\n break;\n default:\n break;\n }\n}\n\n/**\n * Discriminator helper used by codegen, docs, and visitor-table generators.\n *\n * A \"child\" attribute is one whose value contains another node. Specifically,\n * any attribute whose type tree includes a `node`, `nestedUnion`, or\n * `union` is treated as a child. Optionality (the `optional` flag on the\n * attribute itself) is orthogonal to this classification.\n */\nexport function isChildAttribute(type: TypeExpr): boolean {\n switch (type.kind) {\n case 'node':\n case 'nestedUnion':\n case 'union':\n return true;\n case 'array':\n return isChildAttribute(type.of);\n case 'tuple':\n return type.items.some(isChildAttribute);\n default:\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/api/attribute.ts","../src/api/compounds.ts","../src/api/defineCategory.ts","../src/api/defineEnumeration.ts","../src/api/defineNestedUnion.ts","../src/api/defineNode.ts","../src/api/defineUnion.ts","../src/api/primitives.ts","../src/api/semanticAliases.ts","../src/api/validate.ts"],"names":[],"mappings":";;;AAoBO,SAAS,SAAA,CAAU,IAAA,EAAc,IAAA,EAAgB,OAAA,GAA4B,EAAC,EAAkB;AACnG,EAAA,OAAO,OAAO,MAAA,CAAO;AAAA,IACjB,IAAA;AAAA,IACA,IAAA;AAAA,IACA,GAAI,OAAA,CAAQ,QAAA,GAAW,EAAE,QAAA,EAAU,IAAA,KAAkB,EAAC;AAAA,IACtD,GAAI,OAAA,CAAQ,IAAA,KAAS,MAAA,GAAY,EAAE,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,CAAC,GAAG,OAAA,CAAQ,IAAI,CAAC,CAAA,KAAM;AAAC,GAClF,CAAA;AACL;AAMO,SAAS,iBAAA,CACZ,IAAA,EACA,IAAA,EACA,OAAA,GAA8C,EAAC,EAClC;AACb,EAAA,OAAO,SAAA,CAAU,MAAM,IAAA,EAAM,EAAE,GAAG,OAAA,EAAS,QAAA,EAAU,MAAM,CAAA;AAC/D;;;AC3BO,SAAS,MAAM,KAAA,EAA2B;AAC7C,EAAA,OAAO,OAAO,MAAA,CAAO,EAAE,MAAM,OAAA,EAAkB,EAAA,EAAI,OAAO,CAAA;AAC9D;AAOO,SAAS,SAAS,KAAA,EAA6B;AAClD,EAAA,OAAO,MAAA,CAAO,MAAA,CAAO,EAAE,IAAA,EAAM,OAAA,EAAkB,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AiB,IAAA,EAAyB;AACtD,EAAA,QAAQ,KAAK,IAAA;AAAM,IACf,KAAK,MAAA;AAAA,IACL,KAAK,aAAA;AAAA,IACL,KAAK,OAAA;AACD,MAAA,OAAO,IAAA;AAAA,IACX,KAAK,OAAA;AACD,MAAA,OAAO,gBAAA,CAAiB,KAAK,EAAE,CAAA;AAAA,IACnC,KAAK,OAAA;AACD,MAAA,OAAO,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,gBAAgB,CAAA;AAAA,IAC3C;AACI,MAAA,OAAO,KAAA;AAAA;AAEnB","file":"api.node.cjs","sourcesContent":["/**\n * Attribute factories — produce frozen `AttributeSpec` values directly.\n *\n * Every attribute of a node MUST be constructed via one of these helpers.\n * The returned value IS the encoded form; `defineNode` consumes them as-is.\n */\n\nimport type { AttributeSpec, TypeExpr } from './types';\n\nexport interface AttributeOptions {\n /** Free-form prose paragraphs describing this attribute. */\n readonly docs?: readonly string[];\n /** When `true`, the attribute may be absent in encoded values. */\n readonly optional?: boolean;\n}\n\n/**\n * Declare an attribute. The default is a required attribute; pass\n * `{ optional: true }` (or use `optionalAttribute`) to mark it optional.\n */\nexport function attribute(name: string, type: TypeExpr, options: AttributeOptions = {}): AttributeSpec {\n return Object.freeze({\n name,\n type,\n ...(options.optional ? { optional: true as const } : {}),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\n/**\n * Sugar for `attribute(name, type, { optional: true, ...rest })` — the most\n * common attribute shape after required ones.\n */\nexport function optionalAttribute(\n name: string,\n type: TypeExpr,\n options: Omit<AttributeOptions, 'optional'> = {},\n): AttributeSpec {\n return attribute(name, type, { ...options, optional: true });\n}\n","/**\n * Compound type-expression constructors — wrap or combine other type\n * expressions. Returned values are frozen.\n *\n * Optionality is intentionally NOT a compound: it's an attribute-level\n * concern, expressed via `optionalAttribute(...)` or\n * `attribute(..., { optional: true })`.\n */\n\nimport type { TypeExpr } from './types';\n\n/** An array (homogeneous list) of `inner`. */\nexport function array(inner: TypeExpr): TypeExpr {\n return Object.freeze({ kind: 'array' as const, of: inner });\n}\n\n/**\n * A heterogeneous fixed-length tuple. Each positional slot has its own type.\n *\n * Tuples use `items` (plural) rather than `of` to signal cardinality > 1.\n */\nexport function tuple(...items: TypeExpr[]): TypeExpr {\n return Object.freeze({ kind: 'tuple' as const, items: Object.freeze([...items]) });\n}\n","/**\n * `defineCategory(name, options)` — group a coherent set of nodes,\n * unions, enumerations, and nested unions under a single name.\n *\n * Categories double as a filing hint for codegen targets that organise\n * output by category (e.g. the TypeScript node-types generator emits\n * each category into its own subdirectory). Category names are arbitrary\n * strings; the spec doesn't constrain them.\n */\n\nimport type { CategorySpec, EnumerationSpec, NestedUnionSpec, NodeSpec, UnionSpec } from './types';\n\nexport interface DefineCategoryOptions {\n readonly docs?: readonly string[];\n readonly nodes?: readonly NodeSpec[];\n readonly unions?: readonly UnionSpec[];\n readonly enumerations?: readonly EnumerationSpec[];\n readonly nestedUnions?: readonly NestedUnionSpec[];\n}\n\nexport function defineCategory(name: string, options: DefineCategoryOptions = {}): CategorySpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n nodes: Object.freeze([...(options.nodes ?? [])]),\n unions: Object.freeze([...(options.unions ?? [])]),\n enumerations: Object.freeze([...(options.enumerations ?? [])]),\n nestedUnions: Object.freeze([...(options.nestedUnions ?? [])]),\n });\n}\n","/**\n * `defineEnumeration(name, options)` — declares a named enumeration.\n *\n * Codegen emits a string-literal union (TS), a real `enum` (Rust), a class\n * (Python), etc., according to each language's idiom. Per-variant docs are\n * carried through to language-native member documentation.\n */\n\nimport type { EnumerationSpec, EnumerationVariantSpec } from './types';\n\nexport interface VariantOptions {\n readonly docs?: readonly string[];\n}\n\n/** Construct a single enumeration variant. */\nexport function variant(name: string, options: VariantOptions = {}): EnumerationVariantSpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\nexport interface DefineEnumerationOptions {\n readonly docs?: readonly string[];\n readonly variants: readonly EnumerationVariantSpec[];\n}\n\nexport function defineEnumeration(name: string, options: DefineEnumerationOptions): EnumerationSpec {\n if (options.variants.length === 0) {\n throw new Error(`defineEnumeration(\"${name}\"): variants must be non-empty`);\n }\n const seen = new Set<string>();\n for (const v of options.variants) {\n if (seen.has(v.name)) {\n throw new Error(`defineEnumeration(\"${name}\"): duplicate variant \"${v.name}\"`);\n }\n seen.add(v.name);\n }\n return Object.freeze({\n name,\n variants: Object.freeze([...options.variants]),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n","/**\n * `defineNestedUnion(name, options)` — declares a recursive type alias,\n * e.g. `nestedTypeNode<T>`.\n *\n * Codegen renders one alternative per wrapper kind, plus the base case:\n *\n * ```ts\n * type Alias<T extends Base> = Wrapper1<Alias<T>> | Wrapper2<Alias<T>> | … | T;\n * ```\n *\n * Use the `nestedUnion(alias, innerKind)` `TypeExpr` helper to reference\n * an instance of this alias from an attribute.\n */\n\nimport type { NestedUnionSpec, TypeExpr } from './types';\n\nexport interface DefineNestedUnionOptions {\n readonly docs?: readonly string[];\n /**\n * The base type the recursion bottoms out in. Codegen renders this\n * as the alias's type-parameter constraint and as the final union arm.\n */\n readonly base: TypeExpr;\n /**\n * Node kinds that act as wrappers in the recursion. Each must be a\n * node whose attribute structure can wrap another `NestedUnion<T>`.\n */\n readonly wrappers: readonly string[];\n}\n\nexport function defineNestedUnion(name: string, options: DefineNestedUnionOptions): NestedUnionSpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n base: options.base,\n wrappers: Object.freeze([...options.wrappers]),\n });\n}\n","/**\n * `defineNode(kind, options)` — declares a single Codama node.\n *\n * The `kind` string is the discriminator value. By convention it ends in\n * `Node` and uses camelCase (e.g. `accountNode`, `arrayTypeNode`).\n *\n * `attributes` is an ordered array of values produced by `attribute(...)` or\n * `optionalAttribute(...)`. Order is preserved in the encoded spec and, by\n * extension, in generated code. The `kind: literal(<kind>)` discriminator\n * is implicit and is NOT declared by authors.\n *\n * The data-vs-children distinction is derived at codegen time from each\n * attribute's type tree (see `isChildAttribute` in `validate.ts`); the\n * meta-model itself just stores a flat list.\n */\n\nimport type { AttributeSpec, NodeSpec } from './types';\n\nexport interface DefineNodeOptions {\n /** Free-form prose paragraphs describing this node. */\n readonly docs?: readonly string[];\n /**\n * Attributes of the node, in declaration order. Construct each entry\n * via `attribute(...)` or `optionalAttribute(...)`.\n */\n readonly attributes: readonly AttributeSpec[];\n /** Free-form examples (shape defined per spec major version). */\n readonly examples?: readonly unknown[];\n}\n\nexport function defineNode(kind: string, options: DefineNodeOptions): NodeSpec {\n return Object.freeze({\n kind,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n attributes: Object.freeze([...options.attributes]),\n examples: Object.freeze([...(options.examples ?? [])]),\n });\n}\n","/**\n * `defineUnion(name, options)` — declares a named union of nodes.\n *\n * Members can be:\n * - a node kind string (e.g. `'arrayTypeNode'`), or\n * - a `node(...)` / `union(...)` reference (a `TypeExpr` produced by\n * `primitives.ts`).\n *\n * Nested unions are preserved structurally in the encoded spec rather than\n * flattened. This serves two purposes:\n * - DRY authoring (`union('standaloneTypeNode')` instead of repeating 23\n * kind names).\n * - A signal to the Rust codegen to emit `From`/`Into` trait impls between\n * the parent union and each nested union.\n */\n\nimport type { TypeExpr, UnionMember, UnionSpec } from './types';\n\nexport type UnionMemberInput = TypeExpr | string;\n\nexport interface DefineUnionOptions {\n readonly docs?: readonly string[];\n readonly members: readonly UnionMemberInput[];\n}\n\nexport function defineUnion(name: string, options: DefineUnionOptions): UnionSpec {\n const normalised: UnionMember[] = options.members.map(normaliseMember);\n return Object.freeze({\n name,\n members: Object.freeze(normalised),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\nfunction normaliseMember(input: UnionMemberInput): UnionMember {\n if (typeof input === 'string') {\n // Bare strings are treated as node kinds (the most common case).\n return Object.freeze({ kind: 'node' as const, name: input });\n }\n if (input.kind === 'node') return Object.freeze({ kind: 'node' as const, name: input.name });\n if (input.kind === 'union') return Object.freeze({ kind: 'union' as const, name: input.name });\n throw new Error(\n `defineUnion: members must be node kind strings, node(...) or union(...) references; got ${JSON.stringify(input)}`,\n );\n}\n","/**\n * Type-expression primitives — the leaves of any attribute's type tree.\n *\n * Each function returns a frozen `TypeExpr` value. The encoded spec stores\n * those objects verbatim; codegen targets read them and emit native types.\n */\n\nimport type { FloatWidth, IntegerWidth, LiteralValue, StringConstraint, TypeExpr } from './types';\n\n// Addresses.\n\n/**\n * A Solana address (a base58-encoded ed25519 public key on the wire).\n * Codegen targets emit a dedicated address type — e.g. `Address` in Rust —\n * rather than treating it as a generic string.\n */\nexport function address(): TypeExpr {\n return Object.freeze({ kind: 'address' as const });\n}\n\n// Strings.\n\n/** Plain UTF-8 string. */\nexport function string(): TypeExpr {\n return Object.freeze({ kind: 'string' as const });\n}\n\n/**\n * A string that must be a valid IDL identifier (stored canonically in\n * camelCase). Renderers may convert to other casings at output time.\n */\nexport function stringIdentifier(): TypeExpr {\n return Object.freeze({ kind: 'string' as const, constraint: 'identifier' as const });\n}\n\n/** A string that must be a valid version (e.g. `\"1.6.0\"`). */\nexport function stringVersion(): TypeExpr {\n return Object.freeze({ kind: 'string' as const, constraint: 'version' as const });\n}\n\n/**\n * The version string of the surrounding Codama spec. Treat as a brand on\n * top of `stringVersion()` — the value is always pinned to the spec\n * version of the IDL document. Codegen targets typically emit a literal\n * type or a constant.\n */\nexport function codamaVersion(): TypeExpr {\n return Object.freeze({ kind: 'codamaVersion' as const });\n}\n\n// Integers (explicit bit widths — no machine-dependent usize/isize).\n\nconst integer = (width: IntegerWidth): TypeExpr => Object.freeze({ kind: 'integer' as const, width });\n\nexport const u8 = (): TypeExpr => integer('u8');\nexport const u16 = (): TypeExpr => integer('u16');\nexport const u32 = (): TypeExpr => integer('u32');\nexport const u64 = (): TypeExpr => integer('u64');\nexport const u128 = (): TypeExpr => integer('u128');\nexport const i8 = (): TypeExpr => integer('i8');\nexport const i16 = (): TypeExpr => integer('i16');\nexport const i32 = (): TypeExpr => integer('i32');\nexport const i64 = (): TypeExpr => integer('i64');\nexport const i128 = (): TypeExpr => integer('i128');\n\n// Floats.\n\nconst float = (width: FloatWidth): TypeExpr => Object.freeze({ kind: 'float' as const, width });\n\nexport const f32 = (): TypeExpr => float('f32');\nexport const f64 = (): TypeExpr => float('f64');\n\n// Booleans and literals.\n\nexport function boolean(): TypeExpr {\n return Object.freeze({ kind: 'boolean' as const });\n}\n\n/** A single fixed value of a primitive type. */\nexport function literal(value: LiteralValue): TypeExpr {\n return Object.freeze({ kind: 'literal' as const, value });\n}\n\n/**\n * A heterogeneous union of literal values — for sum types like\n * `boolean | 'either'` that don't fit a string-only enumeration.\n *\n * Codegen targets render this as the appropriate language idiom (a literal\n * union in TS, a tagged enum with custom serde in Rust, etc.).\n */\nexport function literalUnion(...values: LiteralValue[]): TypeExpr {\n if (values.length === 0) {\n throw new Error('literalUnion: at least one value required');\n }\n const seen = new Set<LiteralValue>();\n for (const v of values) {\n if (seen.has(v)) {\n throw new Error(`literalUnion: duplicate value ${JSON.stringify(v)}`);\n }\n seen.add(v);\n }\n return Object.freeze({ kind: 'literalUnion' as const, values: Object.freeze([...values]) });\n}\n\n// Named references.\n\n/** Reference to a named enumeration declared via `defineEnumeration`. */\nexport function enumeration(name: string): TypeExpr {\n return Object.freeze({ kind: 'enumeration' as const, name });\n}\n\n/** Reference to a named node declared via `defineNode`. */\nexport function node(name: string): TypeExpr {\n return Object.freeze({ kind: 'node' as const, name });\n}\n\n/** Reference to a named union declared via `defineUnion`. */\nexport function union(name: string): TypeExpr {\n return Object.freeze({ kind: 'union' as const, name });\n}\n\n/**\n * Reference to a named node, wrapped by a named recursive `NestedUnion`\n * alias. `alias` selects which `NestedUnion` declared via\n * `defineNestedUnion` the wrapping uses (e.g. `'nestedTypeNode'`); `name`\n * is the inner node kind.\n *\n * Renderers emit `<alias><<innerInterface>>` and an import for the alias\n * file.\n */\nexport function nestedUnion(alias: string, name: string): TypeExpr {\n return Object.freeze({ kind: 'nestedUnion' as const, alias, name });\n}\n\n// Re-exports for type ergonomics.\nexport type { FloatWidth, IntegerWidth, LiteralValue, StringConstraint, TypeExpr };\n","/**\n * Author-side semantic aliases.\n *\n * Most aliases desugar at call time so the encoded spec only ever shows\n * the underlying primitive (e.g. `{ kind: \"integer\", width: \"u64\" }` for\n * both `u64()` and `byteSize()`). Each language's codegen may further\n * specialise rendering for these widths (e.g. Rust may render `u64` as\n * `usize` for byte-size fields if it wants). Those are codegen policies\n * — not spec content.\n *\n * `docs()` is the exception: it returns its own `'docs'` `TypeExpr` kind\n * so the documentation intent survives in the encoded spec rather than\n * collapsing to `array(string())`.\n */\n\nimport { i64, u32, u64 } from './primitives';\nimport type { TypeExpr } from './types';\n\n/** Number of bytes; non-negative. Encoded as `u64`. */\nexport function byteSize(): TypeExpr {\n return u64();\n}\n\n/** Signed byte offset. Encoded as `i64`. */\nexport function byteOffset(): TypeExpr {\n return i64();\n}\n\n/** Count of items in a collection; non-negative. Encoded as `u32`. */\nexport function count(): TypeExpr {\n return u32();\n}\n\n/**\n * Documentation for a node — semantically a list of paragraph strings,\n * but rendered per language at codegen time (e.g. `Array<string>` in\n * TypeScript, `Vec<String>` in Rust). Returns its own `'docs'` kind so\n * the intent isn't lost in the encoded spec.\n */\nexport function docs(): TypeExpr {\n return Object.freeze({ kind: 'docs' as const });\n}\n","/**\n * Self-consistency validation for an assembled spec.\n *\n * Returns an array of human-readable error strings. An empty array means\n * the spec is internally coherent — every reference resolves, no\n * duplicate names, naming conventions hold.\n */\n\nimport type { EnumerationSpec, NestedUnionSpec, NodeSpec, Spec, TypeExpr, UnionSpec } from './types';\n\ntype RegistryKind = 'enumeration' | 'nestedUnion' | 'node' | 'union';\n\n/**\n * The canonical camelCase identifier shape used across the spec for\n * unions, enumerations, and nested-union aliases. Node kinds must also\n * end in `Node` — see `NODE_KIND_REGEX`.\n */\nconst CAMEL_CASE_REGEX = /^[a-z][A-Za-z0-9]*$/;\nconst NODE_KIND_REGEX = /^[a-z][A-Za-z0-9]*Node$/;\n\nexport function validate(spec: Spec): string[] {\n const errors: string[] = [];\n\n const allNodes: NodeSpec[] = [];\n const allUnions: UnionSpec[] = [];\n const allEnumerations: EnumerationSpec[] = [];\n const allNestedUnions: NestedUnionSpec[] = [];\n for (const c of spec.categories) {\n allNodes.push(...c.nodes);\n allUnions.push(...c.unions);\n allEnumerations.push(...c.enumerations);\n allNestedUnions.push(...c.nestedUnions);\n }\n\n const nodeKinds = new Set(allNodes.map(n => n.kind));\n const unionNames = new Set(allUnions.map(u => u.name));\n const enumerationNames = new Set(allEnumerations.map(e => e.name));\n const nestedUnionNames = new Set(allNestedUnions.map(nu => nu.name));\n\n // Single-pass name-collision check across nodes, unions, enumerations,\n // and nested unions. One error per offending name.\n const registrations = new Map<string, RegistryKind[]>();\n const record = (name: string, kind: RegistryKind): void => {\n const list = registrations.get(name);\n if (list) list.push(kind);\n else registrations.set(name, [kind]);\n };\n for (const n of allNodes) record(n.kind, 'node');\n for (const u of allUnions) record(u.name, 'union');\n for (const e of allEnumerations) record(e.name, 'enumeration');\n for (const nu of allNestedUnions) record(nu.name, 'nestedUnion');\n\n for (const [name, kinds] of registrations) {\n if (kinds.length > 1) errors.push(formatCollisionError(name, kinds));\n }\n\n // Duplicate category names.\n const seenCategories = new Set<string>();\n for (const c of spec.categories) {\n if (seenCategories.has(c.name)) {\n errors.push(`Category \"${c.name}\" is declared more than once.`);\n }\n seenCategories.add(c.name);\n }\n\n // Per-node validation.\n for (const n of allNodes) {\n if (!NODE_KIND_REGEX.test(n.kind)) {\n errors.push(`Node kind \"${n.kind}\" does not match the camelCase ...Node naming convention.`);\n }\n const seenAttrs = new Set<string>();\n for (const a of n.attributes) {\n if (seenAttrs.has(a.name)) {\n errors.push(`Node \"${n.kind}\" declares attribute \"${a.name}\" more than once.`);\n }\n seenAttrs.add(a.name);\n walkTypeExpr(a.type, expr =>\n checkRef(expr, n.kind, a.name, errors, nodeKinds, unionNames, enumerationNames, nestedUnionNames),\n );\n }\n }\n\n // Union member resolution.\n for (const u of allUnions) {\n if (!CAMEL_CASE_REGEX.test(u.name)) {\n errors.push(`Union \"${u.name}\" does not match the camelCase naming convention.`);\n }\n if (u.members.length === 0) {\n errors.push(`Union \"${u.name}\" has no members.`);\n }\n const seenMembers = new Set<string>();\n for (const m of u.members) {\n const key = `${m.kind}:${m.name}`;\n if (seenMembers.has(key)) {\n errors.push(`Union \"${u.name}\" lists member ${key} more than once.`);\n }\n seenMembers.add(key);\n if (m.kind === 'node' && !nodeKinds.has(m.name)) {\n errors.push(`Union \"${u.name}\" references undefined node \"${m.name}\".`);\n }\n if (m.kind === 'union' && !unionNames.has(m.name)) {\n errors.push(`Union \"${u.name}\" references undefined union \"${m.name}\".`);\n }\n }\n }\n\n // Enumeration naming.\n for (const e of allEnumerations) {\n if (!CAMEL_CASE_REGEX.test(e.name)) {\n errors.push(`Enumeration \"${e.name}\" does not match the camelCase naming convention.`);\n }\n }\n\n // Nested-union wrapper sanity.\n for (const nu of allNestedUnions) {\n if (!CAMEL_CASE_REGEX.test(nu.name)) {\n errors.push(`Nested union \"${nu.name}\" does not match the camelCase naming convention.`);\n }\n if (nu.wrappers.length === 0) {\n errors.push(`Nested union \"${nu.name}\" has no wrappers.`);\n }\n for (const w of nu.wrappers) {\n if (!nodeKinds.has(w)) {\n errors.push(`Nested union \"${nu.name}\" wrapper \"${w}\" is not a defined node.`);\n }\n }\n }\n\n return errors;\n}\n\nfunction formatCollisionError(name: string, kinds: RegistryKind[]): string {\n const counts = new Map<RegistryKind, number>();\n for (const k of kinds) counts.set(k, (counts.get(k) ?? 0) + 1);\n const breakdown = [...counts.entries()]\n .sort((a, b) => a[0].localeCompare(b[0]))\n .map(([k, n]) => `${n} ${k}${n > 1 ? 's' : ''}`)\n .join(', ');\n return `Name \"${name}\" is registered ${kinds.length} times (${breakdown}); names must be unique across nodes, unions, enumerations, and nested unions.`;\n}\n\nfunction walkTypeExpr(expr: TypeExpr, visit: (expr: TypeExpr) => void): void {\n visit(expr);\n if (expr.kind === 'array') {\n walkTypeExpr(expr.of, visit);\n } else if (expr.kind === 'tuple') {\n for (const item of expr.items) walkTypeExpr(item, visit);\n }\n}\n\nfunction checkRef(\n expr: TypeExpr,\n nodeKind: string,\n attrName: string,\n errors: string[],\n nodeKinds: Set<string>,\n unionNames: Set<string>,\n enumerationNames: Set<string>,\n nestedUnionNames: Set<string>,\n): void {\n const where = `Node \"${nodeKind}\", attribute \"${attrName}\":`;\n switch (expr.kind) {\n case 'node':\n if (!nodeKinds.has(expr.name)) {\n errors.push(`${where} references undefined node \"${expr.name}\".`);\n }\n break;\n case 'union':\n if (!unionNames.has(expr.name)) {\n errors.push(`${where} references undefined union \"${expr.name}\".`);\n }\n break;\n case 'enumeration':\n if (!enumerationNames.has(expr.name)) {\n errors.push(`${where} references undefined enumeration \"${expr.name}\".`);\n }\n break;\n case 'nestedUnion':\n if (!nodeKinds.has(expr.name)) {\n errors.push(`${where} nestedUnion references undefined node \"${expr.name}\".`);\n }\n if (!nestedUnionNames.has(expr.alias)) {\n errors.push(`${where} nestedUnion references undefined alias \"${expr.alias}\".`);\n }\n break;\n default:\n break;\n }\n}\n\n/**\n * Discriminator helper used by codegen, docs, and visitor-table generators.\n *\n * A \"child\" attribute is one whose value contains another node. Specifically,\n * any attribute whose type tree includes a `node`, `nestedUnion`, or\n * `union` is treated as a child. Optionality (the `optional` flag on the\n * attribute itself) is orthogonal to this classification.\n */\nexport function isChildAttribute(type: TypeExpr): boolean {\n switch (type.kind) {\n case 'node':\n case 'nestedUnion':\n case 'union':\n return true;\n case 'array':\n return isChildAttribute(type.of);\n case 'tuple':\n return type.items.some(isChildAttribute);\n default:\n return false;\n }\n}\n"]}
|
package/dist/api.node.mjs
CHANGED
|
@@ -97,6 +97,9 @@ function normaliseMember(input) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
// src/api/primitives.ts
|
|
100
|
+
function address() {
|
|
101
|
+
return Object.freeze({ kind: "address" });
|
|
102
|
+
}
|
|
100
103
|
function string() {
|
|
101
104
|
return Object.freeze({ kind: "string" });
|
|
102
105
|
}
|
|
@@ -170,6 +173,8 @@ function docs() {
|
|
|
170
173
|
}
|
|
171
174
|
|
|
172
175
|
// src/api/validate.ts
|
|
176
|
+
var CAMEL_CASE_REGEX = /^[a-z][A-Za-z0-9]*$/;
|
|
177
|
+
var NODE_KIND_REGEX = /^[a-z][A-Za-z0-9]*Node$/;
|
|
173
178
|
function validate(spec) {
|
|
174
179
|
const errors = [];
|
|
175
180
|
const allNodes = [];
|
|
@@ -207,7 +212,7 @@ function validate(spec) {
|
|
|
207
212
|
seenCategories.add(c.name);
|
|
208
213
|
}
|
|
209
214
|
for (const n of allNodes) {
|
|
210
|
-
if (
|
|
215
|
+
if (!NODE_KIND_REGEX.test(n.kind)) {
|
|
211
216
|
errors.push(`Node kind "${n.kind}" does not match the camelCase ...Node naming convention.`);
|
|
212
217
|
}
|
|
213
218
|
const seenAttrs = /* @__PURE__ */ new Set();
|
|
@@ -223,6 +228,9 @@ function validate(spec) {
|
|
|
223
228
|
}
|
|
224
229
|
}
|
|
225
230
|
for (const u of allUnions) {
|
|
231
|
+
if (!CAMEL_CASE_REGEX.test(u.name)) {
|
|
232
|
+
errors.push(`Union "${u.name}" does not match the camelCase naming convention.`);
|
|
233
|
+
}
|
|
226
234
|
if (u.members.length === 0) {
|
|
227
235
|
errors.push(`Union "${u.name}" has no members.`);
|
|
228
236
|
}
|
|
@@ -241,7 +249,15 @@ function validate(spec) {
|
|
|
241
249
|
}
|
|
242
250
|
}
|
|
243
251
|
}
|
|
252
|
+
for (const e of allEnumerations) {
|
|
253
|
+
if (!CAMEL_CASE_REGEX.test(e.name)) {
|
|
254
|
+
errors.push(`Enumeration "${e.name}" does not match the camelCase naming convention.`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
244
257
|
for (const nu of allNestedUnions) {
|
|
258
|
+
if (!CAMEL_CASE_REGEX.test(nu.name)) {
|
|
259
|
+
errors.push(`Nested union "${nu.name}" does not match the camelCase naming convention.`);
|
|
260
|
+
}
|
|
245
261
|
if (nu.wrappers.length === 0) {
|
|
246
262
|
errors.push(`Nested union "${nu.name}" has no wrappers.`);
|
|
247
263
|
}
|
|
@@ -310,6 +326,6 @@ function isChildAttribute(type) {
|
|
|
310
326
|
}
|
|
311
327
|
}
|
|
312
328
|
|
|
313
|
-
export { array, attribute, boolean, byteOffset, byteSize, codamaVersion, count, defineCategory, defineEnumeration, defineNestedUnion, defineNode, defineUnion, docs, enumeration, f32, f64, i128, i16, i32, i64, i8, isChildAttribute, literal, literalUnion, nestedUnion, node, optionalAttribute, string, stringIdentifier, stringVersion, tuple, u128, u16, u32, u64, u8, union, validate, variant };
|
|
329
|
+
export { address, array, attribute, boolean, byteOffset, byteSize, codamaVersion, count, defineCategory, defineEnumeration, defineNestedUnion, defineNode, defineUnion, docs, enumeration, f32, f64, i128, i16, i32, i64, i8, isChildAttribute, literal, literalUnion, nestedUnion, node, optionalAttribute, string, stringIdentifier, stringVersion, tuple, u128, u16, u32, u64, u8, union, validate, variant };
|
|
314
330
|
//# sourceMappingURL=api.node.mjs.map
|
|
315
331
|
//# sourceMappingURL=api.node.mjs.map
|
package/dist/api.node.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/attribute.ts","../src/api/compounds.ts","../src/api/defineCategory.ts","../src/api/defineEnumeration.ts","../src/api/defineNestedUnion.ts","../src/api/defineNode.ts","../src/api/defineUnion.ts","../src/api/primitives.ts","../src/api/semanticAliases.ts","../src/api/validate.ts"],"names":[],"mappings":";AAoBO,SAAS,SAAA,CAAU,IAAA,EAAc,IAAA,EAAgB,OAAA,GAA4B,EAAC,EAAkB;AACnG,EAAA,OAAO,OAAO,MAAA,CAA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,OAAA;AACD,MAAA,OAAO,IAAA;AAAA,IACX,KAAK,OAAA;AACD,MAAA,OAAO,gBAAA,CAAiB,KAAK,EAAE,CAAA;AAAA,IACnC,KAAK,OAAA;AACD,MAAA,OAAO,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,gBAAgB,CAAA;AAAA,IAC3C;AACI,MAAA,OAAO,KAAA;AAAA;AAEnB","file":"api.node.mjs","sourcesContent":["/**\n * Attribute factories — produce frozen `AttributeSpec` values directly.\n *\n * Every attribute of a node MUST be constructed via one of these helpers.\n * The returned value IS the encoded form; `defineNode` consumes them as-is.\n */\n\nimport type { AttributeSpec, TypeExpr } from './types';\n\nexport interface AttributeOptions {\n /** Free-form prose paragraphs describing this attribute. */\n readonly docs?: readonly string[];\n /** When `true`, the attribute may be absent in encoded values. */\n readonly optional?: boolean;\n}\n\n/**\n * Declare an attribute. The default is a required attribute; pass\n * `{ optional: true }` (or use `optionalAttribute`) to mark it optional.\n */\nexport function attribute(name: string, type: TypeExpr, options: AttributeOptions = {}): AttributeSpec {\n return Object.freeze({\n name,\n type,\n ...(options.optional ? { optional: true as const } : {}),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\n/**\n * Sugar for `attribute(name, type, { optional: true, ...rest })` — the most\n * common attribute shape after required ones.\n */\nexport function optionalAttribute(\n name: string,\n type: TypeExpr,\n options: Omit<AttributeOptions, 'optional'> = {},\n): AttributeSpec {\n return attribute(name, type, { ...options, optional: true });\n}\n","/**\n * Compound type-expression constructors — wrap or combine other type\n * expressions. Returned values are frozen.\n *\n * Optionality is intentionally NOT a compound: it's an attribute-level\n * concern, expressed via `optionalAttribute(...)` or\n * `attribute(..., { optional: true })`.\n */\n\nimport type { TypeExpr } from './types';\n\n/** An array (homogeneous list) of `inner`. */\nexport function array(inner: TypeExpr): TypeExpr {\n return Object.freeze({ kind: 'array' as const, of: inner });\n}\n\n/**\n * A heterogeneous fixed-length tuple. Each positional slot has its own type.\n *\n * Tuples use `items` (plural) rather than `of` to signal cardinality > 1.\n */\nexport function tuple(...items: TypeExpr[]): TypeExpr {\n return Object.freeze({ kind: 'tuple' as const, items: Object.freeze([...items]) });\n}\n","/**\n * `defineCategory(name, options)` — group a coherent set of nodes,\n * unions, enumerations, and nested unions under a single name.\n *\n * Categories double as a filing hint for codegen targets that organise\n * output by category (e.g. the TypeScript node-types generator emits\n * each category into its own subdirectory). Category names are arbitrary\n * strings; the spec doesn't constrain them.\n */\n\nimport type { CategorySpec, EnumerationSpec, NestedUnionSpec, NodeSpec, UnionSpec } from './types';\n\nexport interface DefineCategoryOptions {\n readonly docs?: readonly string[];\n readonly nodes?: readonly NodeSpec[];\n readonly unions?: readonly UnionSpec[];\n readonly enumerations?: readonly EnumerationSpec[];\n readonly nestedUnions?: readonly NestedUnionSpec[];\n}\n\nexport function defineCategory(name: string, options: DefineCategoryOptions = {}): CategorySpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n nodes: Object.freeze([...(options.nodes ?? [])]),\n unions: Object.freeze([...(options.unions ?? [])]),\n enumerations: Object.freeze([...(options.enumerations ?? [])]),\n nestedUnions: Object.freeze([...(options.nestedUnions ?? [])]),\n });\n}\n","/**\n * `defineEnumeration(name, options)` — declares a named enumeration.\n *\n * Codegen emits a string-literal union (TS), a real `enum` (Rust), a class\n * (Python), etc., according to each language's idiom. Per-variant docs are\n * carried through to language-native member documentation.\n */\n\nimport type { EnumerationSpec, EnumerationVariantSpec } from './types';\n\nexport interface VariantOptions {\n readonly docs?: readonly string[];\n}\n\n/** Construct a single enumeration variant. */\nexport function variant(name: string, options: VariantOptions = {}): EnumerationVariantSpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\nexport interface DefineEnumerationOptions {\n readonly docs?: readonly string[];\n readonly variants: readonly EnumerationVariantSpec[];\n}\n\nexport function defineEnumeration(name: string, options: DefineEnumerationOptions): EnumerationSpec {\n if (options.variants.length === 0) {\n throw new Error(`defineEnumeration(\"${name}\"): variants must be non-empty`);\n }\n const seen = new Set<string>();\n for (const v of options.variants) {\n if (seen.has(v.name)) {\n throw new Error(`defineEnumeration(\"${name}\"): duplicate variant \"${v.name}\"`);\n }\n seen.add(v.name);\n }\n return Object.freeze({\n name,\n variants: Object.freeze([...options.variants]),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n","/**\n * `defineNestedUnion(name, options)` — declares a recursive type alias,\n * e.g. `NestedTypeNode<T>`.\n *\n * Codegen renders one alternative per wrapper kind, plus the base case:\n *\n * ```ts\n * type Alias<T extends Base> = Wrapper1<Alias<T>> | Wrapper2<Alias<T>> | … | T;\n * ```\n *\n * Use the `nestedUnion(alias, innerKind)` `TypeExpr` helper to reference\n * an instance of this alias from an attribute.\n */\n\nimport type { NestedUnionSpec, TypeExpr } from './types';\n\nexport interface DefineNestedUnionOptions {\n readonly docs?: readonly string[];\n /**\n * The base type the recursion bottoms out in. Codegen renders this\n * as the alias's type-parameter constraint and as the final union arm.\n */\n readonly base: TypeExpr;\n /**\n * Node kinds that act as wrappers in the recursion. Each must be a\n * node whose attribute structure can wrap another `NestedUnion<T>`.\n */\n readonly wrappers: readonly string[];\n}\n\nexport function defineNestedUnion(name: string, options: DefineNestedUnionOptions): NestedUnionSpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n base: options.base,\n wrappers: Object.freeze([...options.wrappers]),\n });\n}\n","/**\n * `defineNode(kind, options)` — declares a single Codama node.\n *\n * The `kind` string is the discriminator value. By convention it ends in\n * `Node` and uses camelCase (e.g. `accountNode`, `arrayTypeNode`).\n *\n * `attributes` is an ordered array of values produced by `attribute(...)` or\n * `optionalAttribute(...)`. Order is preserved in the encoded spec and, by\n * extension, in generated code. The `kind: literal(<kind>)` discriminator\n * is implicit and is NOT declared by authors.\n *\n * The data-vs-children distinction is derived at codegen time from each\n * attribute's type tree (see `isChildAttribute` in `validate.ts`); the\n * meta-model itself just stores a flat list.\n */\n\nimport type { AttributeSpec, NodeSpec } from './types';\n\nexport interface DefineNodeOptions {\n /** Free-form prose paragraphs describing this node. */\n readonly docs?: readonly string[];\n /**\n * Attributes of the node, in declaration order. Construct each entry\n * via `attribute(...)` or `optionalAttribute(...)`.\n */\n readonly attributes: readonly AttributeSpec[];\n /** Free-form examples (shape defined per spec major version). */\n readonly examples?: readonly unknown[];\n}\n\nexport function defineNode(kind: string, options: DefineNodeOptions): NodeSpec {\n return Object.freeze({\n kind,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n attributes: Object.freeze([...options.attributes]),\n examples: Object.freeze([...(options.examples ?? [])]),\n });\n}\n","/**\n * `defineUnion(name, options)` — declares a named union of nodes.\n *\n * Members can be:\n * - a node kind string (e.g. `'arrayTypeNode'`), or\n * - a `node(...)` / `union(...)` reference (a `TypeExpr` produced by\n * `primitives.ts`).\n *\n * Nested unions are preserved structurally in the encoded spec rather than\n * flattened. This serves two purposes:\n * - DRY authoring (`union('StandaloneTypeNode')` instead of repeating 23\n * kind names).\n * - A signal to the Rust codegen to emit `From`/`Into` trait impls between\n * the parent union and each nested union.\n */\n\nimport type { TypeExpr, UnionMember, UnionSpec } from './types';\n\nexport type UnionMemberInput = TypeExpr | string;\n\nexport interface DefineUnionOptions {\n readonly docs?: readonly string[];\n readonly members: readonly UnionMemberInput[];\n}\n\nexport function defineUnion(name: string, options: DefineUnionOptions): UnionSpec {\n const normalised: UnionMember[] = options.members.map(normaliseMember);\n return Object.freeze({\n name,\n members: Object.freeze(normalised),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\nfunction normaliseMember(input: UnionMemberInput): UnionMember {\n if (typeof input === 'string') {\n // Bare strings are treated as node kinds (the most common case).\n return Object.freeze({ kind: 'node' as const, name: input });\n }\n if (input.kind === 'node') return Object.freeze({ kind: 'node' as const, name: input.name });\n if (input.kind === 'union') return Object.freeze({ kind: 'union' as const, name: input.name });\n throw new Error(\n `defineUnion: members must be node kind strings, node(...) or union(...) references; got ${JSON.stringify(input)}`,\n );\n}\n","/**\n * Type-expression primitives — the leaves of any attribute's type tree.\n *\n * Each function returns a frozen `TypeExpr` value. The encoded spec stores\n * those objects verbatim; codegen targets read them and emit native types.\n */\n\nimport type { FloatWidth, IntegerWidth, LiteralValue, StringConstraint, TypeExpr } from './types';\n\n// Strings.\n\n/** Plain UTF-8 string. */\nexport function string(): TypeExpr {\n return Object.freeze({ kind: 'string' as const });\n}\n\n/**\n * A string that must be a valid IDL identifier (stored canonically in\n * camelCase). Renderers may convert to other casings at output time.\n */\nexport function stringIdentifier(): TypeExpr {\n return Object.freeze({ kind: 'string' as const, constraint: 'identifier' as const });\n}\n\n/** A string that must be a valid version (e.g. `\"1.6.0\"`). */\nexport function stringVersion(): TypeExpr {\n return Object.freeze({ kind: 'string' as const, constraint: 'version' as const });\n}\n\n/**\n * The version string of the surrounding Codama spec. Treat as a brand on\n * top of `stringVersion()` — the value is always pinned to the spec\n * version of the IDL document. Codegen targets typically emit a literal\n * type or a constant.\n */\nexport function codamaVersion(): TypeExpr {\n return Object.freeze({ kind: 'codamaVersion' as const });\n}\n\n// Integers (explicit bit widths — no machine-dependent usize/isize).\n\nconst integer = (width: IntegerWidth): TypeExpr => Object.freeze({ kind: 'integer' as const, width });\n\nexport const u8 = (): TypeExpr => integer('u8');\nexport const u16 = (): TypeExpr => integer('u16');\nexport const u32 = (): TypeExpr => integer('u32');\nexport const u64 = (): TypeExpr => integer('u64');\nexport const u128 = (): TypeExpr => integer('u128');\nexport const i8 = (): TypeExpr => integer('i8');\nexport const i16 = (): TypeExpr => integer('i16');\nexport const i32 = (): TypeExpr => integer('i32');\nexport const i64 = (): TypeExpr => integer('i64');\nexport const i128 = (): TypeExpr => integer('i128');\n\n// Floats.\n\nconst float = (width: FloatWidth): TypeExpr => Object.freeze({ kind: 'float' as const, width });\n\nexport const f32 = (): TypeExpr => float('f32');\nexport const f64 = (): TypeExpr => float('f64');\n\n// Booleans and literals.\n\nexport function boolean(): TypeExpr {\n return Object.freeze({ kind: 'boolean' as const });\n}\n\n/** A single fixed value of a primitive type. */\nexport function literal(value: LiteralValue): TypeExpr {\n return Object.freeze({ kind: 'literal' as const, value });\n}\n\n/**\n * A heterogeneous union of literal values — for sum types like\n * `boolean | 'either'` that don't fit a string-only enumeration.\n *\n * Codegen targets render this as the appropriate language idiom (a literal\n * union in TS, a tagged enum with custom serde in Rust, etc.).\n */\nexport function literalUnion(...values: LiteralValue[]): TypeExpr {\n if (values.length === 0) {\n throw new Error('literalUnion: at least one value required');\n }\n const seen = new Set<LiteralValue>();\n for (const v of values) {\n if (seen.has(v)) {\n throw new Error(`literalUnion: duplicate value ${JSON.stringify(v)}`);\n }\n seen.add(v);\n }\n return Object.freeze({ kind: 'literalUnion' as const, values: Object.freeze([...values]) });\n}\n\n// Named references.\n\n/** Reference to a named enumeration declared via `defineEnumeration`. */\nexport function enumeration(name: string): TypeExpr {\n return Object.freeze({ kind: 'enumeration' as const, name });\n}\n\n/** Reference to a named node declared via `defineNode`. */\nexport function node(name: string): TypeExpr {\n return Object.freeze({ kind: 'node' as const, name });\n}\n\n/** Reference to a named union declared via `defineUnion`. */\nexport function union(name: string): TypeExpr {\n return Object.freeze({ kind: 'union' as const, name });\n}\n\n/**\n * Reference to a named node, wrapped by a named recursive `NestedUnion`\n * alias. `alias` selects which `NestedUnion` declared via\n * `defineNestedUnion` the wrapping uses (e.g. `'NestedTypeNode'`); `name`\n * is the inner node kind.\n *\n * Renderers emit `<alias><<innerInterface>>` and an import for the alias\n * file.\n */\nexport function nestedUnion(alias: string, name: string): TypeExpr {\n return Object.freeze({ kind: 'nestedUnion' as const, alias, name });\n}\n\n// Re-exports for type ergonomics.\nexport type { FloatWidth, IntegerWidth, LiteralValue, StringConstraint, TypeExpr };\n","/**\n * Author-side semantic aliases.\n *\n * Most aliases desugar at call time so the encoded spec only ever shows\n * the underlying primitive (e.g. `{ kind: \"integer\", width: \"u64\" }` for\n * both `u64()` and `byteSize()`). Each language's codegen may further\n * specialise rendering for these widths (e.g. Rust may render `u64` as\n * `usize` for byte-size fields if it wants). Those are codegen policies\n * — not spec content.\n *\n * `docs()` is the exception: it returns its own `'docs'` `TypeExpr` kind\n * so the documentation intent survives in the encoded spec rather than\n * collapsing to `array(string())`.\n */\n\nimport { i64, u32, u64 } from './primitives';\nimport type { TypeExpr } from './types';\n\n/** Number of bytes; non-negative. Encoded as `u64`. */\nexport function byteSize(): TypeExpr {\n return u64();\n}\n\n/** Signed byte offset. Encoded as `i64`. */\nexport function byteOffset(): TypeExpr {\n return i64();\n}\n\n/** Count of items in a collection; non-negative. Encoded as `u32`. */\nexport function count(): TypeExpr {\n return u32();\n}\n\n/**\n * Documentation for a node — semantically a list of paragraph strings,\n * but rendered per language at codegen time (e.g. `Array<string>` in\n * TypeScript, `Vec<String>` in Rust). Returns its own `'docs'` kind so\n * the intent isn't lost in the encoded spec.\n */\nexport function docs(): TypeExpr {\n return Object.freeze({ kind: 'docs' as const });\n}\n","/**\n * Self-consistency validation for an assembled spec.\n *\n * Returns an array of human-readable error strings. An empty array means\n * the spec is internally coherent — every reference resolves, no\n * duplicate names, naming conventions hold.\n */\n\nimport type { EnumerationSpec, NestedUnionSpec, NodeSpec, Spec, TypeExpr, UnionSpec } from './types';\n\ntype RegistryKind = 'enumeration' | 'nestedUnion' | 'node' | 'union';\n\nexport function validate(spec: Spec): string[] {\n const errors: string[] = [];\n\n const allNodes: NodeSpec[] = [];\n const allUnions: UnionSpec[] = [];\n const allEnumerations: EnumerationSpec[] = [];\n const allNestedUnions: NestedUnionSpec[] = [];\n for (const c of spec.categories) {\n allNodes.push(...c.nodes);\n allUnions.push(...c.unions);\n allEnumerations.push(...c.enumerations);\n allNestedUnions.push(...c.nestedUnions);\n }\n\n const nodeKinds = new Set(allNodes.map(n => n.kind));\n const unionNames = new Set(allUnions.map(u => u.name));\n const enumerationNames = new Set(allEnumerations.map(e => e.name));\n const nestedUnionNames = new Set(allNestedUnions.map(nu => nu.name));\n\n // Single-pass name-collision check across nodes, unions, enumerations,\n // and nested unions. One error per offending name.\n const registrations = new Map<string, RegistryKind[]>();\n const record = (name: string, kind: RegistryKind): void => {\n const list = registrations.get(name);\n if (list) list.push(kind);\n else registrations.set(name, [kind]);\n };\n for (const n of allNodes) record(n.kind, 'node');\n for (const u of allUnions) record(u.name, 'union');\n for (const e of allEnumerations) record(e.name, 'enumeration');\n for (const nu of allNestedUnions) record(nu.name, 'nestedUnion');\n\n for (const [name, kinds] of registrations) {\n if (kinds.length > 1) errors.push(formatCollisionError(name, kinds));\n }\n\n // Duplicate category names.\n const seenCategories = new Set<string>();\n for (const c of spec.categories) {\n if (seenCategories.has(c.name)) {\n errors.push(`Category \"${c.name}\" is declared more than once.`);\n }\n seenCategories.add(c.name);\n }\n\n // Per-node validation.\n for (const n of allNodes) {\n if (!/^[a-z][A-Za-z0-9]*Node$/.test(n.kind)) {\n errors.push(`Node kind \"${n.kind}\" does not match the camelCase ...Node naming convention.`);\n }\n const seenAttrs = new Set<string>();\n for (const a of n.attributes) {\n if (seenAttrs.has(a.name)) {\n errors.push(`Node \"${n.kind}\" declares attribute \"${a.name}\" more than once.`);\n }\n seenAttrs.add(a.name);\n walkTypeExpr(a.type, expr =>\n checkRef(expr, n.kind, a.name, errors, nodeKinds, unionNames, enumerationNames, nestedUnionNames),\n );\n }\n }\n\n // Union member resolution.\n for (const u of allUnions) {\n if (u.members.length === 0) {\n errors.push(`Union \"${u.name}\" has no members.`);\n }\n const seenMembers = new Set<string>();\n for (const m of u.members) {\n const key = `${m.kind}:${m.name}`;\n if (seenMembers.has(key)) {\n errors.push(`Union \"${u.name}\" lists member ${key} more than once.`);\n }\n seenMembers.add(key);\n if (m.kind === 'node' && !nodeKinds.has(m.name)) {\n errors.push(`Union \"${u.name}\" references undefined node \"${m.name}\".`);\n }\n if (m.kind === 'union' && !unionNames.has(m.name)) {\n errors.push(`Union \"${u.name}\" references undefined union \"${m.name}\".`);\n }\n }\n }\n\n // Nested-union wrapper sanity.\n for (const nu of allNestedUnions) {\n if (nu.wrappers.length === 0) {\n errors.push(`Nested union \"${nu.name}\" has no wrappers.`);\n }\n for (const w of nu.wrappers) {\n if (!nodeKinds.has(w)) {\n errors.push(`Nested union \"${nu.name}\" wrapper \"${w}\" is not a defined node.`);\n }\n }\n }\n\n return errors;\n}\n\nfunction formatCollisionError(name: string, kinds: RegistryKind[]): string {\n const counts = new Map<RegistryKind, number>();\n for (const k of kinds) counts.set(k, (counts.get(k) ?? 0) + 1);\n const breakdown = [...counts.entries()]\n .sort((a, b) => a[0].localeCompare(b[0]))\n .map(([k, n]) => `${n} ${k}${n > 1 ? 's' : ''}`)\n .join(', ');\n return `Name \"${name}\" is registered ${kinds.length} times (${breakdown}); names must be unique across nodes, unions, enumerations, and nested unions.`;\n}\n\nfunction walkTypeExpr(expr: TypeExpr, visit: (expr: TypeExpr) => void): void {\n visit(expr);\n if (expr.kind === 'array') {\n walkTypeExpr(expr.of, visit);\n } else if (expr.kind === 'tuple') {\n for (const item of expr.items) walkTypeExpr(item, visit);\n }\n}\n\nfunction checkRef(\n expr: TypeExpr,\n nodeKind: string,\n attrName: string,\n errors: string[],\n nodeKinds: Set<string>,\n unionNames: Set<string>,\n enumerationNames: Set<string>,\n nestedUnionNames: Set<string>,\n): void {\n const where = `Node \"${nodeKind}\", attribute \"${attrName}\":`;\n switch (expr.kind) {\n case 'node':\n if (!nodeKinds.has(expr.name)) {\n errors.push(`${where} references undefined node \"${expr.name}\".`);\n }\n break;\n case 'union':\n if (!unionNames.has(expr.name)) {\n errors.push(`${where} references undefined union \"${expr.name}\".`);\n }\n break;\n case 'enumeration':\n if (!enumerationNames.has(expr.name)) {\n errors.push(`${where} references undefined enumeration \"${expr.name}\".`);\n }\n break;\n case 'nestedUnion':\n if (!nodeKinds.has(expr.name)) {\n errors.push(`${where} nestedUnion references undefined node \"${expr.name}\".`);\n }\n if (!nestedUnionNames.has(expr.alias)) {\n errors.push(`${where} nestedUnion references undefined alias \"${expr.alias}\".`);\n }\n break;\n default:\n break;\n }\n}\n\n/**\n * Discriminator helper used by codegen, docs, and visitor-table generators.\n *\n * A \"child\" attribute is one whose value contains another node. Specifically,\n * any attribute whose type tree includes a `node`, `nestedUnion`, or\n * `union` is treated as a child. Optionality (the `optional` flag on the\n * attribute itself) is orthogonal to this classification.\n */\nexport function isChildAttribute(type: TypeExpr): boolean {\n switch (type.kind) {\n case 'node':\n case 'nestedUnion':\n case 'union':\n return true;\n case 'array':\n return isChildAttribute(type.of);\n case 'tuple':\n return type.items.some(isChildAttribute);\n default:\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/api/attribute.ts","../src/api/compounds.ts","../src/api/defineCategory.ts","../src/api/defineEnumeration.ts","../src/api/defineNestedUnion.ts","../src/api/defineNode.ts","../src/api/defineUnion.ts","../src/api/primitives.ts","../src/api/semanticAliases.ts","../src/api/validate.ts"],"names":[],"mappings":";AAoBO,SAAS,SAAA,CAAU,IAAA,EAAc,IAAA,EAAgB,OAAA,GAA4B,EAAC,EAAkB;AACnG,EAAA,OAAO,OAAO,MAAA,CAAO;AAAA,IACjB,IAAA;AAAA,IACA,IAAA;AAAA,IACA,GAAI,OAAA,CAAQ,QAAA,GAAW,EAAE,QAAA,EAAU,IAAA,KAAkB,EAAC;AAAA,IACtD,GAAI,OAAA,CAAQ,IAAA,KAAS,MAAA,GAAY,EAAE,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,CAAC,GAAG,OAAA,CAAQ,IAAI,CAAC,CAAA,KAAM;AAAC,GAClF,CAAA;AACL;AAMO,SAAS,iBAAA,CACZ,IAAA,EACA,IAAA,EACA,OAAA,GAA8C,EAAC,EAClC;AACb,EAAA,OAAO,SAAA,CAAU,MAAM,IAAA,EAAM,EAAE,GAAG,OAAA,EAAS,QAAA,EAAU,MAAM,CAAA;AAC/D;;;A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AAI,CAAC,gBAAA,CAAiB,GAAA,CAAI,IAAA,CAAK,KAAK,CAAA,EAAG;AACnC,QAAA,MAAA,CAAO,KAAK,CAAA,EAAG,KAAK,CAAA,yCAAA,EAA4C,IAAA,CAAK,KAAK,CAAA,EAAA,CAAI,CAAA;AAAA,MAClF;AACA,MAAA;AAEA;AAEZ;AAUO,SAAS,iBAAiB,IAAA,EAAyB;AACtD,EAAA,QAAQ,KAAK,IAAA;AAAM,IACf,KAAK,MAAA;AAAA,IACL,KAAK,aAAA;AAAA,IACL,KAAK,OAAA;AACD,MAAA,OAAO,IAAA;AAAA,IACX,KAAK,OAAA;AACD,MAAA,OAAO,gBAAA,CAAiB,KAAK,EAAE,CAAA;AAAA,IACnC,KAAK,OAAA;AACD,MAAA,OAAO,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,gBAAgB,CAAA;AAAA,IAC3C;AACI,MAAA,OAAO,KAAA;AAAA;AAEnB","file":"api.node.mjs","sourcesContent":["/**\n * Attribute factories — produce frozen `AttributeSpec` values directly.\n *\n * Every attribute of a node MUST be constructed via one of these helpers.\n * The returned value IS the encoded form; `defineNode` consumes them as-is.\n */\n\nimport type { AttributeSpec, TypeExpr } from './types';\n\nexport interface AttributeOptions {\n /** Free-form prose paragraphs describing this attribute. */\n readonly docs?: readonly string[];\n /** When `true`, the attribute may be absent in encoded values. */\n readonly optional?: boolean;\n}\n\n/**\n * Declare an attribute. The default is a required attribute; pass\n * `{ optional: true }` (or use `optionalAttribute`) to mark it optional.\n */\nexport function attribute(name: string, type: TypeExpr, options: AttributeOptions = {}): AttributeSpec {\n return Object.freeze({\n name,\n type,\n ...(options.optional ? { optional: true as const } : {}),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\n/**\n * Sugar for `attribute(name, type, { optional: true, ...rest })` — the most\n * common attribute shape after required ones.\n */\nexport function optionalAttribute(\n name: string,\n type: TypeExpr,\n options: Omit<AttributeOptions, 'optional'> = {},\n): AttributeSpec {\n return attribute(name, type, { ...options, optional: true });\n}\n","/**\n * Compound type-expression constructors — wrap or combine other type\n * expressions. Returned values are frozen.\n *\n * Optionality is intentionally NOT a compound: it's an attribute-level\n * concern, expressed via `optionalAttribute(...)` or\n * `attribute(..., { optional: true })`.\n */\n\nimport type { TypeExpr } from './types';\n\n/** An array (homogeneous list) of `inner`. */\nexport function array(inner: TypeExpr): TypeExpr {\n return Object.freeze({ kind: 'array' as const, of: inner });\n}\n\n/**\n * A heterogeneous fixed-length tuple. Each positional slot has its own type.\n *\n * Tuples use `items` (plural) rather than `of` to signal cardinality > 1.\n */\nexport function tuple(...items: TypeExpr[]): TypeExpr {\n return Object.freeze({ kind: 'tuple' as const, items: Object.freeze([...items]) });\n}\n","/**\n * `defineCategory(name, options)` — group a coherent set of nodes,\n * unions, enumerations, and nested unions under a single name.\n *\n * Categories double as a filing hint for codegen targets that organise\n * output by category (e.g. the TypeScript node-types generator emits\n * each category into its own subdirectory). Category names are arbitrary\n * strings; the spec doesn't constrain them.\n */\n\nimport type { CategorySpec, EnumerationSpec, NestedUnionSpec, NodeSpec, UnionSpec } from './types';\n\nexport interface DefineCategoryOptions {\n readonly docs?: readonly string[];\n readonly nodes?: readonly NodeSpec[];\n readonly unions?: readonly UnionSpec[];\n readonly enumerations?: readonly EnumerationSpec[];\n readonly nestedUnions?: readonly NestedUnionSpec[];\n}\n\nexport function defineCategory(name: string, options: DefineCategoryOptions = {}): CategorySpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n nodes: Object.freeze([...(options.nodes ?? [])]),\n unions: Object.freeze([...(options.unions ?? [])]),\n enumerations: Object.freeze([...(options.enumerations ?? [])]),\n nestedUnions: Object.freeze([...(options.nestedUnions ?? [])]),\n });\n}\n","/**\n * `defineEnumeration(name, options)` — declares a named enumeration.\n *\n * Codegen emits a string-literal union (TS), a real `enum` (Rust), a class\n * (Python), etc., according to each language's idiom. Per-variant docs are\n * carried through to language-native member documentation.\n */\n\nimport type { EnumerationSpec, EnumerationVariantSpec } from './types';\n\nexport interface VariantOptions {\n readonly docs?: readonly string[];\n}\n\n/** Construct a single enumeration variant. */\nexport function variant(name: string, options: VariantOptions = {}): EnumerationVariantSpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\nexport interface DefineEnumerationOptions {\n readonly docs?: readonly string[];\n readonly variants: readonly EnumerationVariantSpec[];\n}\n\nexport function defineEnumeration(name: string, options: DefineEnumerationOptions): EnumerationSpec {\n if (options.variants.length === 0) {\n throw new Error(`defineEnumeration(\"${name}\"): variants must be non-empty`);\n }\n const seen = new Set<string>();\n for (const v of options.variants) {\n if (seen.has(v.name)) {\n throw new Error(`defineEnumeration(\"${name}\"): duplicate variant \"${v.name}\"`);\n }\n seen.add(v.name);\n }\n return Object.freeze({\n name,\n variants: Object.freeze([...options.variants]),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n","/**\n * `defineNestedUnion(name, options)` — declares a recursive type alias,\n * e.g. `nestedTypeNode<T>`.\n *\n * Codegen renders one alternative per wrapper kind, plus the base case:\n *\n * ```ts\n * type Alias<T extends Base> = Wrapper1<Alias<T>> | Wrapper2<Alias<T>> | … | T;\n * ```\n *\n * Use the `nestedUnion(alias, innerKind)` `TypeExpr` helper to reference\n * an instance of this alias from an attribute.\n */\n\nimport type { NestedUnionSpec, TypeExpr } from './types';\n\nexport interface DefineNestedUnionOptions {\n readonly docs?: readonly string[];\n /**\n * The base type the recursion bottoms out in. Codegen renders this\n * as the alias's type-parameter constraint and as the final union arm.\n */\n readonly base: TypeExpr;\n /**\n * Node kinds that act as wrappers in the recursion. Each must be a\n * node whose attribute structure can wrap another `NestedUnion<T>`.\n */\n readonly wrappers: readonly string[];\n}\n\nexport function defineNestedUnion(name: string, options: DefineNestedUnionOptions): NestedUnionSpec {\n return Object.freeze({\n name,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n base: options.base,\n wrappers: Object.freeze([...options.wrappers]),\n });\n}\n","/**\n * `defineNode(kind, options)` — declares a single Codama node.\n *\n * The `kind` string is the discriminator value. By convention it ends in\n * `Node` and uses camelCase (e.g. `accountNode`, `arrayTypeNode`).\n *\n * `attributes` is an ordered array of values produced by `attribute(...)` or\n * `optionalAttribute(...)`. Order is preserved in the encoded spec and, by\n * extension, in generated code. The `kind: literal(<kind>)` discriminator\n * is implicit and is NOT declared by authors.\n *\n * The data-vs-children distinction is derived at codegen time from each\n * attribute's type tree (see `isChildAttribute` in `validate.ts`); the\n * meta-model itself just stores a flat list.\n */\n\nimport type { AttributeSpec, NodeSpec } from './types';\n\nexport interface DefineNodeOptions {\n /** Free-form prose paragraphs describing this node. */\n readonly docs?: readonly string[];\n /**\n * Attributes of the node, in declaration order. Construct each entry\n * via `attribute(...)` or `optionalAttribute(...)`.\n */\n readonly attributes: readonly AttributeSpec[];\n /** Free-form examples (shape defined per spec major version). */\n readonly examples?: readonly unknown[];\n}\n\nexport function defineNode(kind: string, options: DefineNodeOptions): NodeSpec {\n return Object.freeze({\n kind,\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n attributes: Object.freeze([...options.attributes]),\n examples: Object.freeze([...(options.examples ?? [])]),\n });\n}\n","/**\n * `defineUnion(name, options)` — declares a named union of nodes.\n *\n * Members can be:\n * - a node kind string (e.g. `'arrayTypeNode'`), or\n * - a `node(...)` / `union(...)` reference (a `TypeExpr` produced by\n * `primitives.ts`).\n *\n * Nested unions are preserved structurally in the encoded spec rather than\n * flattened. This serves two purposes:\n * - DRY authoring (`union('standaloneTypeNode')` instead of repeating 23\n * kind names).\n * - A signal to the Rust codegen to emit `From`/`Into` trait impls between\n * the parent union and each nested union.\n */\n\nimport type { TypeExpr, UnionMember, UnionSpec } from './types';\n\nexport type UnionMemberInput = TypeExpr | string;\n\nexport interface DefineUnionOptions {\n readonly docs?: readonly string[];\n readonly members: readonly UnionMemberInput[];\n}\n\nexport function defineUnion(name: string, options: DefineUnionOptions): UnionSpec {\n const normalised: UnionMember[] = options.members.map(normaliseMember);\n return Object.freeze({\n name,\n members: Object.freeze(normalised),\n ...(options.docs !== undefined ? { docs: Object.freeze([...options.docs]) } : {}),\n });\n}\n\nfunction normaliseMember(input: UnionMemberInput): UnionMember {\n if (typeof input === 'string') {\n // Bare strings are treated as node kinds (the most common case).\n return Object.freeze({ kind: 'node' as const, name: input });\n }\n if (input.kind === 'node') return Object.freeze({ kind: 'node' as const, name: input.name });\n if (input.kind === 'union') return Object.freeze({ kind: 'union' as const, name: input.name });\n throw new Error(\n `defineUnion: members must be node kind strings, node(...) or union(...) references; got ${JSON.stringify(input)}`,\n );\n}\n","/**\n * Type-expression primitives — the leaves of any attribute's type tree.\n *\n * Each function returns a frozen `TypeExpr` value. The encoded spec stores\n * those objects verbatim; codegen targets read them and emit native types.\n */\n\nimport type { FloatWidth, IntegerWidth, LiteralValue, StringConstraint, TypeExpr } from './types';\n\n// Addresses.\n\n/**\n * A Solana address (a base58-encoded ed25519 public key on the wire).\n * Codegen targets emit a dedicated address type — e.g. `Address` in Rust —\n * rather than treating it as a generic string.\n */\nexport function address(): TypeExpr {\n return Object.freeze({ kind: 'address' as const });\n}\n\n// Strings.\n\n/** Plain UTF-8 string. */\nexport function string(): TypeExpr {\n return Object.freeze({ kind: 'string' as const });\n}\n\n/**\n * A string that must be a valid IDL identifier (stored canonically in\n * camelCase). Renderers may convert to other casings at output time.\n */\nexport function stringIdentifier(): TypeExpr {\n return Object.freeze({ kind: 'string' as const, constraint: 'identifier' as const });\n}\n\n/** A string that must be a valid version (e.g. `\"1.6.0\"`). */\nexport function stringVersion(): TypeExpr {\n return Object.freeze({ kind: 'string' as const, constraint: 'version' as const });\n}\n\n/**\n * The version string of the surrounding Codama spec. Treat as a brand on\n * top of `stringVersion()` — the value is always pinned to the spec\n * version of the IDL document. Codegen targets typically emit a literal\n * type or a constant.\n */\nexport function codamaVersion(): TypeExpr {\n return Object.freeze({ kind: 'codamaVersion' as const });\n}\n\n// Integers (explicit bit widths — no machine-dependent usize/isize).\n\nconst integer = (width: IntegerWidth): TypeExpr => Object.freeze({ kind: 'integer' as const, width });\n\nexport const u8 = (): TypeExpr => integer('u8');\nexport const u16 = (): TypeExpr => integer('u16');\nexport const u32 = (): TypeExpr => integer('u32');\nexport const u64 = (): TypeExpr => integer('u64');\nexport const u128 = (): TypeExpr => integer('u128');\nexport const i8 = (): TypeExpr => integer('i8');\nexport const i16 = (): TypeExpr => integer('i16');\nexport const i32 = (): TypeExpr => integer('i32');\nexport const i64 = (): TypeExpr => integer('i64');\nexport const i128 = (): TypeExpr => integer('i128');\n\n// Floats.\n\nconst float = (width: FloatWidth): TypeExpr => Object.freeze({ kind: 'float' as const, width });\n\nexport const f32 = (): TypeExpr => float('f32');\nexport const f64 = (): TypeExpr => float('f64');\n\n// Booleans and literals.\n\nexport function boolean(): TypeExpr {\n return Object.freeze({ kind: 'boolean' as const });\n}\n\n/** A single fixed value of a primitive type. */\nexport function literal(value: LiteralValue): TypeExpr {\n return Object.freeze({ kind: 'literal' as const, value });\n}\n\n/**\n * A heterogeneous union of literal values — for sum types like\n * `boolean | 'either'` that don't fit a string-only enumeration.\n *\n * Codegen targets render this as the appropriate language idiom (a literal\n * union in TS, a tagged enum with custom serde in Rust, etc.).\n */\nexport function literalUnion(...values: LiteralValue[]): TypeExpr {\n if (values.length === 0) {\n throw new Error('literalUnion: at least one value required');\n }\n const seen = new Set<LiteralValue>();\n for (const v of values) {\n if (seen.has(v)) {\n throw new Error(`literalUnion: duplicate value ${JSON.stringify(v)}`);\n }\n seen.add(v);\n }\n return Object.freeze({ kind: 'literalUnion' as const, values: Object.freeze([...values]) });\n}\n\n// Named references.\n\n/** Reference to a named enumeration declared via `defineEnumeration`. */\nexport function enumeration(name: string): TypeExpr {\n return Object.freeze({ kind: 'enumeration' as const, name });\n}\n\n/** Reference to a named node declared via `defineNode`. */\nexport function node(name: string): TypeExpr {\n return Object.freeze({ kind: 'node' as const, name });\n}\n\n/** Reference to a named union declared via `defineUnion`. */\nexport function union(name: string): TypeExpr {\n return Object.freeze({ kind: 'union' as const, name });\n}\n\n/**\n * Reference to a named node, wrapped by a named recursive `NestedUnion`\n * alias. `alias` selects which `NestedUnion` declared via\n * `defineNestedUnion` the wrapping uses (e.g. `'nestedTypeNode'`); `name`\n * is the inner node kind.\n *\n * Renderers emit `<alias><<innerInterface>>` and an import for the alias\n * file.\n */\nexport function nestedUnion(alias: string, name: string): TypeExpr {\n return Object.freeze({ kind: 'nestedUnion' as const, alias, name });\n}\n\n// Re-exports for type ergonomics.\nexport type { FloatWidth, IntegerWidth, LiteralValue, StringConstraint, TypeExpr };\n","/**\n * Author-side semantic aliases.\n *\n * Most aliases desugar at call time so the encoded spec only ever shows\n * the underlying primitive (e.g. `{ kind: \"integer\", width: \"u64\" }` for\n * both `u64()` and `byteSize()`). Each language's codegen may further\n * specialise rendering for these widths (e.g. Rust may render `u64` as\n * `usize` for byte-size fields if it wants). Those are codegen policies\n * — not spec content.\n *\n * `docs()` is the exception: it returns its own `'docs'` `TypeExpr` kind\n * so the documentation intent survives in the encoded spec rather than\n * collapsing to `array(string())`.\n */\n\nimport { i64, u32, u64 } from './primitives';\nimport type { TypeExpr } from './types';\n\n/** Number of bytes; non-negative. Encoded as `u64`. */\nexport function byteSize(): TypeExpr {\n return u64();\n}\n\n/** Signed byte offset. Encoded as `i64`. */\nexport function byteOffset(): TypeExpr {\n return i64();\n}\n\n/** Count of items in a collection; non-negative. Encoded as `u32`. */\nexport function count(): TypeExpr {\n return u32();\n}\n\n/**\n * Documentation for a node — semantically a list of paragraph strings,\n * but rendered per language at codegen time (e.g. `Array<string>` in\n * TypeScript, `Vec<String>` in Rust). Returns its own `'docs'` kind so\n * the intent isn't lost in the encoded spec.\n */\nexport function docs(): TypeExpr {\n return Object.freeze({ kind: 'docs' as const });\n}\n","/**\n * Self-consistency validation for an assembled spec.\n *\n * Returns an array of human-readable error strings. An empty array means\n * the spec is internally coherent — every reference resolves, no\n * duplicate names, naming conventions hold.\n */\n\nimport type { EnumerationSpec, NestedUnionSpec, NodeSpec, Spec, TypeExpr, UnionSpec } from './types';\n\ntype RegistryKind = 'enumeration' | 'nestedUnion' | 'node' | 'union';\n\n/**\n * The canonical camelCase identifier shape used across the spec for\n * unions, enumerations, and nested-union aliases. Node kinds must also\n * end in `Node` — see `NODE_KIND_REGEX`.\n */\nconst CAMEL_CASE_REGEX = /^[a-z][A-Za-z0-9]*$/;\nconst NODE_KIND_REGEX = /^[a-z][A-Za-z0-9]*Node$/;\n\nexport function validate(spec: Spec): string[] {\n const errors: string[] = [];\n\n const allNodes: NodeSpec[] = [];\n const allUnions: UnionSpec[] = [];\n const allEnumerations: EnumerationSpec[] = [];\n const allNestedUnions: NestedUnionSpec[] = [];\n for (const c of spec.categories) {\n allNodes.push(...c.nodes);\n allUnions.push(...c.unions);\n allEnumerations.push(...c.enumerations);\n allNestedUnions.push(...c.nestedUnions);\n }\n\n const nodeKinds = new Set(allNodes.map(n => n.kind));\n const unionNames = new Set(allUnions.map(u => u.name));\n const enumerationNames = new Set(allEnumerations.map(e => e.name));\n const nestedUnionNames = new Set(allNestedUnions.map(nu => nu.name));\n\n // Single-pass name-collision check across nodes, unions, enumerations,\n // and nested unions. One error per offending name.\n const registrations = new Map<string, RegistryKind[]>();\n const record = (name: string, kind: RegistryKind): void => {\n const list = registrations.get(name);\n if (list) list.push(kind);\n else registrations.set(name, [kind]);\n };\n for (const n of allNodes) record(n.kind, 'node');\n for (const u of allUnions) record(u.name, 'union');\n for (const e of allEnumerations) record(e.name, 'enumeration');\n for (const nu of allNestedUnions) record(nu.name, 'nestedUnion');\n\n for (const [name, kinds] of registrations) {\n if (kinds.length > 1) errors.push(formatCollisionError(name, kinds));\n }\n\n // Duplicate category names.\n const seenCategories = new Set<string>();\n for (const c of spec.categories) {\n if (seenCategories.has(c.name)) {\n errors.push(`Category \"${c.name}\" is declared more than once.`);\n }\n seenCategories.add(c.name);\n }\n\n // Per-node validation.\n for (const n of allNodes) {\n if (!NODE_KIND_REGEX.test(n.kind)) {\n errors.push(`Node kind \"${n.kind}\" does not match the camelCase ...Node naming convention.`);\n }\n const seenAttrs = new Set<string>();\n for (const a of n.attributes) {\n if (seenAttrs.has(a.name)) {\n errors.push(`Node \"${n.kind}\" declares attribute \"${a.name}\" more than once.`);\n }\n seenAttrs.add(a.name);\n walkTypeExpr(a.type, expr =>\n checkRef(expr, n.kind, a.name, errors, nodeKinds, unionNames, enumerationNames, nestedUnionNames),\n );\n }\n }\n\n // Union member resolution.\n for (const u of allUnions) {\n if (!CAMEL_CASE_REGEX.test(u.name)) {\n errors.push(`Union \"${u.name}\" does not match the camelCase naming convention.`);\n }\n if (u.members.length === 0) {\n errors.push(`Union \"${u.name}\" has no members.`);\n }\n const seenMembers = new Set<string>();\n for (const m of u.members) {\n const key = `${m.kind}:${m.name}`;\n if (seenMembers.has(key)) {\n errors.push(`Union \"${u.name}\" lists member ${key} more than once.`);\n }\n seenMembers.add(key);\n if (m.kind === 'node' && !nodeKinds.has(m.name)) {\n errors.push(`Union \"${u.name}\" references undefined node \"${m.name}\".`);\n }\n if (m.kind === 'union' && !unionNames.has(m.name)) {\n errors.push(`Union \"${u.name}\" references undefined union \"${m.name}\".`);\n }\n }\n }\n\n // Enumeration naming.\n for (const e of allEnumerations) {\n if (!CAMEL_CASE_REGEX.test(e.name)) {\n errors.push(`Enumeration \"${e.name}\" does not match the camelCase naming convention.`);\n }\n }\n\n // Nested-union wrapper sanity.\n for (const nu of allNestedUnions) {\n if (!CAMEL_CASE_REGEX.test(nu.name)) {\n errors.push(`Nested union \"${nu.name}\" does not match the camelCase naming convention.`);\n }\n if (nu.wrappers.length === 0) {\n errors.push(`Nested union \"${nu.name}\" has no wrappers.`);\n }\n for (const w of nu.wrappers) {\n if (!nodeKinds.has(w)) {\n errors.push(`Nested union \"${nu.name}\" wrapper \"${w}\" is not a defined node.`);\n }\n }\n }\n\n return errors;\n}\n\nfunction formatCollisionError(name: string, kinds: RegistryKind[]): string {\n const counts = new Map<RegistryKind, number>();\n for (const k of kinds) counts.set(k, (counts.get(k) ?? 0) + 1);\n const breakdown = [...counts.entries()]\n .sort((a, b) => a[0].localeCompare(b[0]))\n .map(([k, n]) => `${n} ${k}${n > 1 ? 's' : ''}`)\n .join(', ');\n return `Name \"${name}\" is registered ${kinds.length} times (${breakdown}); names must be unique across nodes, unions, enumerations, and nested unions.`;\n}\n\nfunction walkTypeExpr(expr: TypeExpr, visit: (expr: TypeExpr) => void): void {\n visit(expr);\n if (expr.kind === 'array') {\n walkTypeExpr(expr.of, visit);\n } else if (expr.kind === 'tuple') {\n for (const item of expr.items) walkTypeExpr(item, visit);\n }\n}\n\nfunction checkRef(\n expr: TypeExpr,\n nodeKind: string,\n attrName: string,\n errors: string[],\n nodeKinds: Set<string>,\n unionNames: Set<string>,\n enumerationNames: Set<string>,\n nestedUnionNames: Set<string>,\n): void {\n const where = `Node \"${nodeKind}\", attribute \"${attrName}\":`;\n switch (expr.kind) {\n case 'node':\n if (!nodeKinds.has(expr.name)) {\n errors.push(`${where} references undefined node \"${expr.name}\".`);\n }\n break;\n case 'union':\n if (!unionNames.has(expr.name)) {\n errors.push(`${where} references undefined union \"${expr.name}\".`);\n }\n break;\n case 'enumeration':\n if (!enumerationNames.has(expr.name)) {\n errors.push(`${where} references undefined enumeration \"${expr.name}\".`);\n }\n break;\n case 'nestedUnion':\n if (!nodeKinds.has(expr.name)) {\n errors.push(`${where} nestedUnion references undefined node \"${expr.name}\".`);\n }\n if (!nestedUnionNames.has(expr.alias)) {\n errors.push(`${where} nestedUnion references undefined alias \"${expr.alias}\".`);\n }\n break;\n default:\n break;\n }\n}\n\n/**\n * Discriminator helper used by codegen, docs, and visitor-table generators.\n *\n * A \"child\" attribute is one whose value contains another node. Specifically,\n * any attribute whose type tree includes a `node`, `nestedUnion`, or\n * `union` is treated as a child. Optionality (the `optional` flag on the\n * attribute itself) is orthogonal to this classification.\n */\nexport function isChildAttribute(type: TypeExpr): boolean {\n switch (type.kind) {\n case 'node':\n case 'nestedUnion':\n case 'union':\n return true;\n case 'array':\n return isChildAttribute(type.of);\n case 'tuple':\n return type.items.some(isChildAttribute);\n default:\n return false;\n }\n}\n"]}
|
|
@@ -97,6 +97,9 @@ function normaliseMember(input) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
// src/api/primitives.ts
|
|
100
|
+
function address() {
|
|
101
|
+
return Object.freeze({ kind: "address" });
|
|
102
|
+
}
|
|
100
103
|
function string() {
|
|
101
104
|
return Object.freeze({ kind: "string" });
|
|
102
105
|
}
|
|
@@ -170,6 +173,8 @@ function docs() {
|
|
|
170
173
|
}
|
|
171
174
|
|
|
172
175
|
// src/api/validate.ts
|
|
176
|
+
var CAMEL_CASE_REGEX = /^[a-z][A-Za-z0-9]*$/;
|
|
177
|
+
var NODE_KIND_REGEX = /^[a-z][A-Za-z0-9]*Node$/;
|
|
173
178
|
function validate(spec) {
|
|
174
179
|
const errors = [];
|
|
175
180
|
const allNodes = [];
|
|
@@ -207,7 +212,7 @@ function validate(spec) {
|
|
|
207
212
|
seenCategories.add(c.name);
|
|
208
213
|
}
|
|
209
214
|
for (const n of allNodes) {
|
|
210
|
-
if (
|
|
215
|
+
if (!NODE_KIND_REGEX.test(n.kind)) {
|
|
211
216
|
errors.push(`Node kind "${n.kind}" does not match the camelCase ...Node naming convention.`);
|
|
212
217
|
}
|
|
213
218
|
const seenAttrs = /* @__PURE__ */ new Set();
|
|
@@ -223,6 +228,9 @@ function validate(spec) {
|
|
|
223
228
|
}
|
|
224
229
|
}
|
|
225
230
|
for (const u of allUnions) {
|
|
231
|
+
if (!CAMEL_CASE_REGEX.test(u.name)) {
|
|
232
|
+
errors.push(`Union "${u.name}" does not match the camelCase naming convention.`);
|
|
233
|
+
}
|
|
226
234
|
if (u.members.length === 0) {
|
|
227
235
|
errors.push(`Union "${u.name}" has no members.`);
|
|
228
236
|
}
|
|
@@ -241,7 +249,15 @@ function validate(spec) {
|
|
|
241
249
|
}
|
|
242
250
|
}
|
|
243
251
|
}
|
|
252
|
+
for (const e of allEnumerations) {
|
|
253
|
+
if (!CAMEL_CASE_REGEX.test(e.name)) {
|
|
254
|
+
errors.push(`Enumeration "${e.name}" does not match the camelCase naming convention.`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
244
257
|
for (const nu of allNestedUnions) {
|
|
258
|
+
if (!CAMEL_CASE_REGEX.test(nu.name)) {
|
|
259
|
+
errors.push(`Nested union "${nu.name}" does not match the camelCase naming convention.`);
|
|
260
|
+
}
|
|
245
261
|
if (nu.wrappers.length === 0) {
|
|
246
262
|
errors.push(`Nested union "${nu.name}" has no wrappers.`);
|
|
247
263
|
}
|
|
@@ -310,6 +326,6 @@ function isChildAttribute(type) {
|
|
|
310
326
|
}
|
|
311
327
|
}
|
|
312
328
|
|
|
313
|
-
export { array, attribute, boolean, byteOffset, byteSize, codamaVersion, count, defineCategory, defineEnumeration, defineNestedUnion, defineNode, defineUnion, docs, enumeration, f32, f64, i128, i16, i32, i64, i8, isChildAttribute, literal, literalUnion, nestedUnion, node, optionalAttribute, string, stringIdentifier, stringVersion, tuple, u128, u16, u32, u64, u8, union, validate, variant };
|
|
329
|
+
export { address, array, attribute, boolean, byteOffset, byteSize, codamaVersion, count, defineCategory, defineEnumeration, defineNestedUnion, defineNode, defineUnion, docs, enumeration, f32, f64, i128, i16, i32, i64, i8, isChildAttribute, literal, literalUnion, nestedUnion, node, optionalAttribute, string, stringIdentifier, stringVersion, tuple, u128, u16, u32, u64, u8, union, validate, variant };
|
|
314
330
|
//# sourceMappingURL=api.react-native.mjs.map
|
|
315
331
|
//# sourceMappingURL=api.react-native.mjs.map
|