@type-bridge/node 1.5.5 → 1.5.7

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 CHANGED
@@ -13,8 +13,9 @@ JavaScript values, and exposes TypeScript-friendly wrappers.
13
13
  npm run build
14
14
  ```
15
15
 
16
- The package entry is `index.js`, with declarations emitted to
17
- `dist/index.d.ts`.
16
+ The package entry is `dist/index.js`, with declarations emitted to
17
+ `dist/index.d.ts`. The additive typed-query subpath resolves to
18
+ `dist/typed/index.js` and `dist/typed/index.d.ts`.
18
19
 
19
20
  For local smoke runs after `cargo build -p type-bridge-node`, copy the built
20
21
  library to a `.node` file or point the loader at one:
@@ -23,6 +24,21 @@ library to a `.node` file or point the loader at one:
23
24
  TYPE_BRIDGE_NODE_NATIVE_PATH=/path/to/type_bridge_node.node npm run smoke:package
24
25
  ```
25
26
 
27
+ ## Prebuilt Native Targets
28
+
29
+ The published npm tarball contains all native modules selected by the package
30
+ loader:
31
+
32
+ - Linux glibc on x64 and arm64
33
+ - macOS on x64 and arm64
34
+ - Windows on x64 and arm64
35
+
36
+ Release CI builds each module on its matching native GitHub-hosted runner,
37
+ combines the six immutable outputs into one tarball, and executes that tarball
38
+ on every target. Node 18 is the supported runtime floor; the full platform
39
+ matrix runs on Node 20, with an additional Node 18 acceptance run on Linux x64.
40
+ Linux musl and processor architectures outside this list are not prebuilt.
41
+
26
42
  ## Public Surface
27
43
 
28
44
  ```ts
@@ -46,6 +62,7 @@ const person = registry.registerEntity({
46
62
  value_type: "string",
47
63
  annotations: ["Key"],
48
64
  is_optional: false,
65
+ is_ordered: false,
49
66
  },
50
67
  {
51
68
  field_name: "age",
@@ -53,6 +70,7 @@ const person = registry.registerEntity({
53
70
  value_type: "long",
54
71
  annotations: [],
55
72
  is_optional: true,
73
+ is_ordered: false,
56
74
  },
57
75
  ],
58
76
  });
@@ -69,6 +87,43 @@ const manager = db.entityManager(person);
69
87
  manager.insert(attrs);
70
88
  ```
71
89
 
90
+ ## Immutable Typed Queries
91
+
92
+ The additive `./typed` subpath builds owner-aware matches over the same model
93
+ constructors. It does not replace the package-root managers or raw query
94
+ surface:
95
+
96
+ ```ts
97
+ import { Entity, Key, attr, field } from "@type-bridge/node";
98
+ import { QuerySession, references } from "@type-bridge/node/typed";
99
+
100
+ class PersonName extends attr.String("person-name") {}
101
+ class Person extends Entity("person", {
102
+ name: field(PersonName, Key),
103
+ }) {}
104
+
105
+ const session = new QuerySession(db);
106
+ const person = session.var(Person);
107
+ const personRefs = references(Person);
108
+
109
+ const page = session.query(person).pageBy(person, {
110
+ limit: 25,
111
+ orderBy: [person.field(personRefs.fields.name).asc()],
112
+ includeTotal: true,
113
+ });
114
+ ```
115
+
116
+ Variables, bound fields and roles, predicates, orders, and queries retain
117
+ opaque native handles. `references(Model)` returns frozen, owner-branded
118
+ JavaScript reference tokens; resolving one against a variable creates the
119
+ native field or role handle. The same immutable `Query` supports exact or
120
+ subtype matching, 1–16 selected models, hidden graph witnesses,
121
+ named/collected pages, distinct-root counts, and existence checks. Subtype
122
+ queries must register constructors that JavaScript cannot discover with
123
+ `session.registerModels(...)`. See the
124
+ [typed-query guide](https://ds1sqe.github.io/type-bridge/guide/typed-queries/)
125
+ for the complete contract and transaction rules.
126
+
72
127
  ## Descriptor Shape
73
128
 
74
129
  Descriptors use the canonical Rust serde shape:
@@ -79,7 +134,8 @@ Descriptors use the canonical Rust serde shape:
79
134
  - Owned attributes: `field_name` is the JavaScript-facing field key,
80
135
  `attr_name` is the TypeDB attribute label, `value_type` is one TypeDB
81
136
  primitive value type, `annotations` carries `Key`, `Unique`, or `Card`, and
82
- `is_optional` mirrors the model field optionality.
137
+ `is_optional` mirrors the model field optionality. `is_ordered` declares
138
+ ordered multi-valued storage and is required even when `false`.
83
139
  - Relation roles: `role_name`, accepted `player_type_names`, and optional
84
140
  `[min, max]` cardinality.
85
141
 
@@ -101,6 +157,7 @@ and transaction handles, entity and relation managers, insert/put/update/get,
101
157
  batch insert/put, count, aggregate, group-by aggregate, relation role-player
102
158
  filters, and IID deletes.
103
159
 
104
- The facade does not expose a TypeScript query compiler or a direct TypeDB
105
- driver. Use `npm run scope:probe` to verify the Node crate stays inside that
106
- boundary.
160
+ The facade does not expose a direct TypeDB driver or accept caller-provided
161
+ TypeQL for the immutable typed path. Its native Rust compiler and validator own
162
+ the semantic plan and execution boundary. Use `npm run scope:probe` to verify
163
+ the Node crate stays inside that boundary.
@@ -1,15 +1,17 @@
1
1
  import type { AttributeSchemaEntry, ValueType } from "./index.js";
2
2
  import { AggregateSpec, ComparisonExpr, SortExpr } from "./query.js";
3
3
  declare const attributeBrand: unique symbol;
4
+ declare const attributeCategory: unique symbol;
4
5
  /**
5
6
  * Base class for a branded attribute value. `Value` is the wrapped runtime
6
7
  * value; `Brand` is the schema attribute name carried as a phantom type so that
7
8
  * distinct attribute classes are nominally distinct at compile time. Instances
8
9
  * are immutable; equality is by `(constructor, value)`.
9
10
  */
10
- export declare abstract class Attribute<Value, Brand extends string> {
11
+ export declare abstract class Attribute<Value, Brand extends string, Category extends ValueType = ValueType> {
11
12
  readonly value: Value;
12
13
  readonly [attributeBrand]: Brand;
14
+ readonly [attributeCategory]: Category;
13
15
  constructor(value: Value);
14
16
  equals(other: unknown): boolean;
15
17
  toString(): string;
@@ -56,6 +58,10 @@ export interface AttributeTypeOptions {
56
58
  readonly regex?: string | null;
57
59
  readonly values?: readonly string[] | null;
58
60
  readonly range?: readonly [string | null, string | null] | null;
61
+ /** TypeDB 3.12+ `@doc("...")` documentation for the attribute type. */
62
+ readonly doc?: string;
63
+ /** TypeDB 3.12+ `@meta("key", "value")` annotations, one value per key. */
64
+ readonly meta?: Record<string, string>;
59
65
  }
60
66
  /**
61
67
  * The abstract base class returned by an `attr.*(name)` factory: an abstract
@@ -63,21 +69,21 @@ export interface AttributeTypeOptions {
63
69
  * wire `valueType`. Users extend it (`class Name extends attr.String("name") {}`);
64
70
  * they never name this type directly.
65
71
  */
66
- export type AttributeBase<Value, Brand extends string> = (abstract new (value: Value) => Attribute<Value, Brand>) & {
72
+ export type AttributeBase<Value, Brand extends string, Category extends ValueType = ValueType> = (abstract new (value: Value) => Attribute<Value, Brand, Category>) & {
67
73
  readonly attrName: Brand;
68
- readonly valueType: ValueType;
74
+ readonly valueType: Category;
69
75
  readonly attributeSchema: AttributeSchemaEntry;
70
76
  readonly attributeSchemaEntries: readonly AttributeSchemaEntry[];
71
77
  };
72
78
  /** Attribute base with comparison + sort helpers (every value type). */
73
- export type ComparableAttributeBase<Value, Brand extends string> = AttributeBase<Value, Brand> & ComparisonStatics<Value, Brand> & OrderStatics;
79
+ export type ComparableAttributeBase<Value, Brand extends string, Category extends ValueType = ValueType> = AttributeBase<Value, Brand, Category> & ComparisonStatics<Value, Brand> & OrderStatics;
74
80
  /** Attribute base for string values: comparison + sort + string matching. */
75
- export type StringAttributeBase<Brand extends string> = ComparableAttributeBase<string, Brand> & StringStatics;
81
+ export type StringAttributeBase<Brand extends string> = ComparableAttributeBase<string, Brand, "string"> & StringStatics;
76
82
  /** Attribute base for numeric values: comparison + sort + reduce helpers. */
77
- export type NumericAttributeBase<Value, Brand extends string> = ComparableAttributeBase<Value, Brand> & AggregateStatics;
78
- type ComparableFactory<Value> = <const Name extends string>(name: Name, options?: AttributeTypeOptions) => ComparableAttributeBase<Value, Name>;
83
+ export type NumericAttributeBase<Value, Brand extends string, Category extends "long" | "double" | "decimal" = "long" | "double" | "decimal"> = ComparableAttributeBase<Value, Brand, Category> & AggregateStatics;
84
+ type ComparableFactory<Value, Category extends ValueType> = <const Name extends string>(name: Name, options?: AttributeTypeOptions) => ComparableAttributeBase<Value, Name, Category>;
79
85
  type StringFactory = <const Name extends string>(name: Name, options?: AttributeTypeOptions) => StringAttributeBase<Name>;
80
- type NumericFactory<Value> = <const Name extends string>(name: Name, options?: AttributeTypeOptions) => NumericAttributeBase<Value, Name>;
86
+ type NumericFactory<Value, Category extends "long" | "double" | "decimal"> = <const Name extends string>(name: Name, options?: AttributeTypeOptions) => NumericAttributeBase<Value, Name, Category>;
81
87
  /**
82
88
  * Attribute base-class factories, one per TypeDB value type. Each call returns a
83
89
  * branded base to extend: the mandatory `name` is both the schema `attr_name`
@@ -90,13 +96,13 @@ type NumericFactory<Value> = <const Name extends string>(name: Name, options?: A
90
96
  */
91
97
  export declare const attr: {
92
98
  readonly String: StringFactory;
93
- readonly Integer: NumericFactory<bigint>;
94
- readonly Double: NumericFactory<number>;
95
- readonly Boolean: ComparableFactory<boolean>;
96
- readonly Date: ComparableFactory<string>;
97
- readonly DateTime: ComparableFactory<string>;
98
- readonly DateTimeTZ: ComparableFactory<string>;
99
- readonly Decimal: NumericFactory<string>;
100
- readonly Duration: ComparableFactory<string>;
99
+ readonly Integer: NumericFactory<bigint, "long">;
100
+ readonly Double: NumericFactory<number, "double">;
101
+ readonly Boolean: ComparableFactory<boolean, "boolean">;
102
+ readonly Date: ComparableFactory<string, "date">;
103
+ readonly DateTime: ComparableFactory<string, "datetime">;
104
+ readonly DateTimeTZ: ComparableFactory<string, "datetime-tz">;
105
+ readonly Decimal: NumericFactory<string, "decimal">;
106
+ readonly Duration: ComparableFactory<string, "duration">;
101
107
  };
102
108
  export {};
package/dist/attribute.js CHANGED
@@ -103,6 +103,12 @@ function buildAttributeSchema(attrName, valueType, options) {
103
103
  if (options.range !== undefined) {
104
104
  entry.range = options.range == null ? null : [options.range[0], options.range[1]];
105
105
  }
106
+ if (options.doc !== undefined) {
107
+ entry.doc = options.doc;
108
+ }
109
+ if (options.meta !== undefined && Object.keys(options.meta).length > 0) {
110
+ entry.meta = { ...options.meta };
111
+ }
106
112
  return entry;
107
113
  }
108
114
  function buildAttributeSchemaEntries(entry, options) {
package/dist/flags.d.ts CHANGED
@@ -9,25 +9,37 @@ export declare enum TypeNameCase {
9
9
  CLASS_NAME = "classname",
10
10
  SNAKE_CASE = "snake_case"
11
11
  }
12
- export interface TypeFlagsOptions {
13
- name?: string | null;
12
+ export interface TypeFlagsOptions<Name extends string | null = string | null> {
13
+ name?: Name;
14
14
  abstract?: boolean;
15
15
  base?: boolean;
16
16
  case?: TypeNameCase;
17
+ /** TypeDB 3.12+ `@doc("...")` documentation for the type. */
18
+ doc?: string | null;
19
+ /** TypeDB 3.12+ `@meta("key", "value")` annotations, one value per key. */
20
+ meta?: Record<string, string>;
17
21
  }
18
- export interface ResolvedTypeFlags {
19
- readonly name: string | null;
22
+ export interface ResolvedTypeFlags<Name extends string | null = string | null> {
23
+ readonly name: Name;
20
24
  readonly abstract: boolean;
21
25
  readonly base: boolean;
22
26
  readonly case: TypeNameCase;
27
+ readonly doc: string | null;
28
+ readonly meta: Record<string, string>;
23
29
  }
24
30
  export interface AttributeFlagsOptions {
25
31
  name?: string | null;
26
32
  case?: TypeNameCase | null;
33
+ /** TypeDB 3.12+ `@doc("...")` documentation for the attribute type. */
34
+ doc?: string | null;
35
+ /** TypeDB 3.12+ `@meta("key", "value")` annotations, one value per key. */
36
+ meta?: Record<string, string>;
27
37
  }
28
38
  export interface ResolvedAttributeFlags {
29
39
  readonly name: string | null;
30
40
  readonly case: TypeNameCase | null;
41
+ readonly doc: string | null;
42
+ readonly meta: Record<string, string>;
31
43
  }
32
44
  export interface CardSpec<Min extends number = number, Max extends number | null = number | null> {
33
45
  readonly kind: "card";
@@ -40,6 +52,10 @@ export interface FlagSpec {
40
52
  readonly cardinality: [number, number | null] | null;
41
53
  readonly isOrdered: boolean;
42
54
  readonly isDistinct: boolean;
55
+ /** TypeDB 3.12+ `@doc("...")` documentation for the ownership. */
56
+ readonly doc: string | null;
57
+ /** TypeDB 3.12+ `@meta("key", "value")` annotations for the ownership. */
58
+ readonly meta: Record<string, string>;
43
59
  }
44
60
  /** Marks a field as the type's key attribute (implies cardinality `[1, 1]`). */
45
61
  export declare const Key = "Key";
@@ -49,9 +65,32 @@ export declare const Unique = "Unique";
49
65
  export declare const Ordered = "Ordered";
50
66
  /** Emits `@distinct` on the owns clause. Requires `Ordered`. Schema-only. */
51
67
  export declare const Distinct = "Distinct";
52
- export type FlagInput = typeof Key | typeof Unique | typeof Ordered | typeof Distinct | CardSpec | FlagSpec;
68
+ /** TypeDB 3.12+ `@doc("...")` marker for one ownership. */
69
+ export interface DocSpec {
70
+ readonly kind: "doc";
71
+ readonly text: string;
72
+ }
73
+ /** TypeDB 3.12+ `@meta("key", "value")` marker for one ownership. */
74
+ export interface MetaSpec {
75
+ readonly kind: "meta";
76
+ readonly key: string;
77
+ readonly value: string;
78
+ }
79
+ /** Documentation marker for the TypeDB 3.12+ `@doc("...")` ownership annotation. */
80
+ export declare function Doc(text: string): DocSpec;
81
+ /** Metadata marker for the TypeDB 3.12+ `@meta("key", "value")` ownership annotation. */
82
+ export declare function Meta(key: string, value: string): MetaSpec;
83
+ export type FlagInput = typeof Key | typeof Unique | typeof Ordered | typeof Distinct | CardSpec | FlagSpec | DocSpec | MetaSpec;
84
+ type NamelessTypeFlagsOptions = Omit<TypeFlagsOptions, "name"> & {
85
+ readonly name?: never;
86
+ };
53
87
  /** Type-level config for an `Entity`/`Relation` (explicit name, abstract, base, case). */
54
- export declare function TypeFlags(options?: TypeFlagsOptions): ResolvedTypeFlags;
88
+ export declare function TypeFlags(): ResolvedTypeFlags<null>;
89
+ export declare function TypeFlags(options: NamelessTypeFlagsOptions): ResolvedTypeFlags<null>;
90
+ export declare function TypeFlags<const Name extends string | null>(options: TypeFlagsOptions<Name> & {
91
+ readonly name: Name;
92
+ }): ResolvedTypeFlags<Name>;
93
+ export declare function TypeFlags(options: TypeFlagsOptions): ResolvedTypeFlags;
55
94
  /** Attribute-level config: an explicit attribute name and/or case override. */
56
95
  export declare function AttributeFlags(options?: AttributeFlagsOptions): ResolvedAttributeFlags;
57
96
  /** A cardinality bound `[min, max]`. Omitting `max` means unbounded (`[min, null]`). */
@@ -65,3 +104,4 @@ export declare function Flag(...flags: FlagInput[]): FlagSpec;
65
104
  export declare function resolveFlags(flags: readonly FlagInput[]): FlagSpec;
66
105
  /** Convert a model class name to its TypeDB type name under the given case. */
67
106
  export declare function formatTypeName(className: string, typeCase: TypeNameCase): string;
107
+ export {};
package/dist/flags.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Distinct = exports.Ordered = exports.Unique = exports.Key = exports.TypeNameCase = void 0;
4
+ exports.Doc = Doc;
5
+ exports.Meta = Meta;
4
6
  exports.TypeFlags = TypeFlags;
5
7
  exports.AttributeFlags = AttributeFlags;
6
8
  exports.Card = Card;
@@ -26,13 +28,22 @@ exports.Unique = "Unique";
26
28
  exports.Ordered = "Ordered";
27
29
  /** Emits `@distinct` on the owns clause. Requires `Ordered`. Schema-only. */
28
30
  exports.Distinct = "Distinct";
29
- /** Type-level config for an `Entity`/`Relation` (explicit name, abstract, base, case). */
31
+ /** Documentation marker for the TypeDB 3.12+ `@doc("...")` ownership annotation. */
32
+ function Doc(text) {
33
+ return { kind: "doc", text };
34
+ }
35
+ /** Metadata marker for the TypeDB 3.12+ `@meta("key", "value")` ownership annotation. */
36
+ function Meta(key, value) {
37
+ return { kind: "meta", key, value };
38
+ }
30
39
  function TypeFlags(options = {}) {
31
40
  return {
32
41
  name: options.name ?? null,
33
42
  abstract: options.abstract ?? false,
34
43
  base: options.base ?? false,
35
44
  case: options.case ?? TypeNameCase.CLASS_NAME,
45
+ doc: options.doc ?? null,
46
+ meta: { ...(options.meta ?? {}) },
36
47
  };
37
48
  }
38
49
  /** Attribute-level config: an explicit attribute name and/or case override. */
@@ -40,6 +51,8 @@ function AttributeFlags(options = {}) {
40
51
  return {
41
52
  name: options.name ?? null,
42
53
  case: options.case ?? null,
54
+ doc: options.doc ?? null,
55
+ meta: { ...(options.meta ?? {}) },
43
56
  };
44
57
  }
45
58
  /** A cardinality bound `[min, max]`. Omitting `max` means unbounded (`[min, null]`). */
@@ -63,12 +76,24 @@ function resolveFlags(flags) {
63
76
  let cardinality = null;
64
77
  let isOrdered = false;
65
78
  let isDistinct = false;
79
+ let doc = null;
80
+ const meta = {};
66
81
  for (const flag of flags) {
67
82
  if (isFlagSpec(flag)) {
68
83
  annotations.push(...flag.annotations);
69
84
  cardinality = flag.cardinality ?? cardinality;
70
85
  isOrdered = isOrdered || flag.isOrdered;
71
86
  isDistinct = isDistinct || flag.isDistinct;
87
+ doc = flag.doc ?? doc;
88
+ Object.assign(meta, flag.meta);
89
+ continue;
90
+ }
91
+ if (isDocSpec(flag)) {
92
+ doc = flag.text;
93
+ continue;
94
+ }
95
+ if (isMetaSpec(flag)) {
96
+ meta[flag.key] = flag.value;
72
97
  continue;
73
98
  }
74
99
  if (flag === exports.Key) {
@@ -97,7 +122,7 @@ function resolveFlags(flags) {
97
122
  if (isDistinct && !isOrdered) {
98
123
  throw new TypeError("Flag(Distinct) requires Flag(Ordered): @distinct is only valid on a list attribute (owns attr[]).");
99
124
  }
100
- return { kind: "flag", annotations, cardinality, isOrdered, isDistinct };
125
+ return { kind: "flag", annotations, cardinality, isOrdered, isDistinct, doc, meta };
101
126
  }
102
127
  /** Convert a model class name to its TypeDB type name under the given case. */
103
128
  function formatTypeName(className, typeCase) {
@@ -115,6 +140,12 @@ function toSnakeCase(name) {
115
140
  .replace(/([a-z0-9])([A-Z])/g, "$1_$2")
116
141
  .toLowerCase();
117
142
  }
143
+ function isDocSpec(flag) {
144
+ return typeof flag === "object" && flag !== null && flag.kind === "doc";
145
+ }
146
+ function isMetaSpec(flag) {
147
+ return typeof flag === "object" && flag !== null && flag.kind === "meta";
148
+ }
118
149
  function isCardSpec(flag) {
119
150
  return typeof flag === "object" && flag !== null && flag.kind === "card";
120
151
  }
package/dist/index.d.ts CHANGED
@@ -19,12 +19,20 @@ export interface OwnedAttributeDescriptor {
19
19
  regex?: string | null;
20
20
  allowed_values?: string[] | null;
21
21
  range?: [string | null, string | null] | null;
22
+ /** TypeDB 3.12+ `@doc("...")` annotation. Omitted when not declared. */
23
+ doc?: string;
24
+ /** TypeDB 3.12+ `@meta("key", "value")` annotations, keyed by meta key. */
25
+ meta?: Record<string, string>;
22
26
  }
23
27
  export interface EntityDescriptor {
24
28
  type_name: string;
25
29
  is_abstract: boolean;
26
30
  parent_type: string | null;
27
31
  owned_attributes: OwnedAttributeDescriptor[];
32
+ /** TypeDB 3.12+ `@doc("...")` annotation. Omitted when not declared. */
33
+ doc?: string;
34
+ /** TypeDB 3.12+ `@meta("key", "value")` annotations, keyed by meta key. */
35
+ meta?: Record<string, string>;
28
36
  }
29
37
  export interface RoleDescriptor {
30
38
  role_name: string;
@@ -42,6 +50,10 @@ export interface RoleDescriptor {
42
50
  ordered: boolean;
43
51
  /** Whether this role carries `@distinct`. Valid only when `ordered` is true. */
44
52
  distinct: boolean;
53
+ /** TypeDB 3.12+ `@doc("...")` annotation. Omitted when not declared. */
54
+ doc?: string;
55
+ /** TypeDB 3.12+ `@meta("key", "value")` annotations, keyed by meta key. */
56
+ meta?: Record<string, string>;
45
57
  }
46
58
  export interface RelationDescriptor {
47
59
  type_name: string;
@@ -49,6 +61,10 @@ export interface RelationDescriptor {
49
61
  parent_type: string | null;
50
62
  owned_attributes: OwnedAttributeDescriptor[];
51
63
  roles: RoleDescriptor[];
64
+ /** TypeDB 3.12+ `@doc("...")` annotation. Omitted when not declared. */
65
+ doc?: string;
66
+ /** TypeDB 3.12+ `@meta("key", "value")` annotations, keyed by meta key. */
67
+ meta?: Record<string, string>;
52
68
  }
53
69
  export type TypeDescriptor = {
54
70
  kind: "entity";
@@ -65,6 +81,10 @@ export interface OwnedAttributeEntry {
65
81
  * Instance-level list semantics are engine-unimplemented (REP256); this is a
66
82
  * schema-emission marker only. */
67
83
  is_ordered: boolean;
84
+ /** TypeDB 3.12+ `@doc("...")` annotation. Omitted when not declared. */
85
+ doc?: string;
86
+ /** TypeDB 3.12+ `@meta("key", "value")` annotations, keyed by meta key. */
87
+ meta?: Record<string, string>;
68
88
  }
69
89
  export interface RoleEntry {
70
90
  role_name: string;
@@ -81,6 +101,10 @@ export interface RoleEntry {
81
101
  ordered: boolean;
82
102
  /** Whether this role carries `@distinct`. Valid only when `ordered` is true. */
83
103
  distinct: boolean;
104
+ /** TypeDB 3.12+ `@doc("...")` annotation. Omitted when not declared. */
105
+ doc?: string;
106
+ /** TypeDB 3.12+ `@meta("key", "value")` annotations, keyed by meta key. */
107
+ meta?: Record<string, string>;
84
108
  }
85
109
  export interface EntitySchemaEntry {
86
110
  type_name: string;
@@ -88,6 +112,10 @@ export interface EntitySchemaEntry {
88
112
  parent_type: string | null;
89
113
  owned_attributes: OwnedAttributeEntry[];
90
114
  plays_cardinalities?: Record<string, [number, number | null]>;
115
+ /** TypeDB 3.12+ `@doc("...")` annotation. Omitted when not declared. */
116
+ doc?: string;
117
+ /** TypeDB 3.12+ `@meta("key", "value")` annotations, keyed by meta key. */
118
+ meta?: Record<string, string>;
91
119
  }
92
120
  export interface RelationSchemaEntry extends EntitySchemaEntry {
93
121
  roles: RoleEntry[];
@@ -101,6 +129,10 @@ export interface AttributeSchemaEntry {
101
129
  regex?: string | null;
102
130
  allowed_values?: string[] | null;
103
131
  range?: [string | null, string | null] | null;
132
+ /** TypeDB 3.12+ `@doc("...")` annotation. Omitted when not declared. */
133
+ doc?: string;
134
+ /** TypeDB 3.12+ `@meta("key", "value")` annotations, keyed by meta key. */
135
+ meta?: Record<string, string>;
104
136
  }
105
137
  export interface SchemaInfo {
106
138
  entities: Record<string, EntitySchemaEntry>;
@@ -186,7 +218,7 @@ export type RuntimeAttributeValue = {
186
218
  };
187
219
  export { Attribute, attr, type AttributeBase, type AttributeTypeOptions, type AttributeTypeParent, type ComparableAttributeBase, type NumericAttributeBase, type StringAttributeBase, } from "./attribute.js";
188
220
  export { AggregateSpec, BooleanExpr, ComparisonExpr, NotExpr, QueryExpr, SortExpr, TypedGroupByQuery, TypedQuery, TypedQueryError, agg, } from "./query.js";
189
- export { AttributeFlags, Card, Flag, Key, TypeFlags, TypeNameCase, Unique, formatTypeName, resolveFlags, type AttributeFlagsOptions, type CardSpec, type FlagInput, type FlagSpec, type ResolvedAttributeFlags, type ResolvedTypeFlags, type TypeFlagsOptions, } from "./flags.js";
221
+ export { AttributeFlags, Card, Doc, Flag, Key, Meta, TypeFlags, TypeNameCase, Unique, formatTypeName, resolveFlags, type AttributeFlagsOptions, type CardSpec, type DocSpec, type FlagInput, type FlagSpec, type MetaSpec, type ResolvedAttributeFlags, type ResolvedTypeFlags, type TypeFlagsOptions, } from "./flags.js";
190
222
  export { Entity, FieldSpec, ListFieldSpec, Relation, RoleSpec, field, role, type AttributeClass, type EntitySchema, type FieldValue, type IidBearing, type InstanceDict, type InstanceFields, type MergedSchema, type ModelClass, type ModelInstance, type ParentModelClass, type ParentOption, type PlainFieldValue, type RelationSchema, type SchemaSpec, } from "./model.js";
191
223
  export { TypedCodecError, attributeToPlain, hydrateAttributeEntries, hydrateAttributes, keyAttributeDescriptor, lowerAttributes, lowerAttributeValue, lowerFilters, plainToAttribute, runtimeAttributeValueFromUnknown, } from "./codec.js";
192
224
  export { TypedEntityManager, TypedRelationManager, buildRolePlayers, entityManagerFor, relationManagerFor, type ExactFilters, type ManagerConnection, } from "./manager.js";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RustDynamicEntityManager = exports.RustTransactionContext = exports.RustDatabase = exports.Marshalling = exports.DescriptorRegistry = exports.loadNative = exports.parseSchema = exports.relationManagerFor = exports.entityManagerFor = exports.buildRolePlayers = exports.TypedRelationManager = exports.TypedEntityManager = exports.runtimeAttributeValueFromUnknown = exports.plainToAttribute = exports.lowerFilters = exports.lowerAttributeValue = exports.lowerAttributes = exports.keyAttributeDescriptor = exports.hydrateAttributes = exports.hydrateAttributeEntries = exports.attributeToPlain = exports.TypedCodecError = exports.role = exports.field = exports.RoleSpec = exports.Relation = exports.ListFieldSpec = exports.FieldSpec = exports.Entity = exports.resolveFlags = exports.formatTypeName = exports.Unique = exports.TypeNameCase = exports.TypeFlags = exports.Key = exports.Flag = exports.Card = exports.AttributeFlags = exports.agg = exports.TypedQueryError = exports.TypedQuery = exports.TypedGroupByQuery = exports.SortExpr = exports.QueryExpr = exports.NotExpr = exports.ComparisonExpr = exports.BooleanExpr = exports.AggregateSpec = exports.attr = exports.Attribute = void 0;
4
- exports.generateModelsForTarget = exports.generateModels = exports.RustDynamicRelationManager = void 0;
3
+ exports.RustDatabase = exports.Marshalling = exports.DescriptorRegistry = exports.loadNative = exports.parseSchema = exports.relationManagerFor = exports.entityManagerFor = exports.buildRolePlayers = exports.TypedRelationManager = exports.TypedEntityManager = exports.runtimeAttributeValueFromUnknown = exports.plainToAttribute = exports.lowerFilters = exports.lowerAttributeValue = exports.lowerAttributes = exports.keyAttributeDescriptor = exports.hydrateAttributes = exports.hydrateAttributeEntries = exports.attributeToPlain = exports.TypedCodecError = exports.role = exports.field = exports.RoleSpec = exports.Relation = exports.ListFieldSpec = exports.FieldSpec = exports.Entity = exports.resolveFlags = exports.formatTypeName = exports.Unique = exports.TypeNameCase = exports.TypeFlags = exports.Meta = exports.Key = exports.Flag = exports.Doc = exports.Card = exports.AttributeFlags = exports.agg = exports.TypedQueryError = exports.TypedQuery = exports.TypedGroupByQuery = exports.SortExpr = exports.QueryExpr = exports.NotExpr = exports.ComparisonExpr = exports.BooleanExpr = exports.AggregateSpec = exports.attr = exports.Attribute = void 0;
4
+ exports.generateModelsForTarget = exports.generateModels = exports.RustDynamicRelationManager = exports.RustDynamicEntityManager = exports.RustTransactionContext = void 0;
5
5
  exports.string = string;
6
6
  exports.long = long;
7
7
  exports.longFromNumberUnsafe = longFromNumberUnsafe;
@@ -16,6 +16,7 @@ exports.ensureDatabase = ensureDatabase;
16
16
  exports.generateDefineBlock = generateDefineBlock;
17
17
  const native_js_1 = require("./native.js");
18
18
  Object.defineProperty(exports, "loadNative", { enumerable: true, get: function () { return native_js_1.loadNative; } });
19
+ const runtime_handles_js_1 = require("./typed/runtime-handles.js");
19
20
  const ATTRIBUTE_SCHEMA_METADATA = Symbol.for("@type-bridge/node.attributeSchemaMetadata");
20
21
  var attribute_js_1 = require("./attribute.js");
21
22
  Object.defineProperty(exports, "Attribute", { enumerable: true, get: function () { return attribute_js_1.Attribute; } });
@@ -34,8 +35,10 @@ Object.defineProperty(exports, "agg", { enumerable: true, get: function () { ret
34
35
  var flags_js_1 = require("./flags.js");
35
36
  Object.defineProperty(exports, "AttributeFlags", { enumerable: true, get: function () { return flags_js_1.AttributeFlags; } });
36
37
  Object.defineProperty(exports, "Card", { enumerable: true, get: function () { return flags_js_1.Card; } });
38
+ Object.defineProperty(exports, "Doc", { enumerable: true, get: function () { return flags_js_1.Doc; } });
37
39
  Object.defineProperty(exports, "Flag", { enumerable: true, get: function () { return flags_js_1.Flag; } });
38
40
  Object.defineProperty(exports, "Key", { enumerable: true, get: function () { return flags_js_1.Key; } });
41
+ Object.defineProperty(exports, "Meta", { enumerable: true, get: function () { return flags_js_1.Meta; } });
39
42
  Object.defineProperty(exports, "TypeFlags", { enumerable: true, get: function () { return flags_js_1.TypeFlags; } });
40
43
  Object.defineProperty(exports, "TypeNameCase", { enumerable: true, get: function () { return flags_js_1.TypeNameCase; } });
41
44
  Object.defineProperty(exports, "Unique", { enumerable: true, get: function () { return flags_js_1.Unique; } });
@@ -256,6 +259,7 @@ class RustDatabase {
256
259
  #native;
257
260
  constructor(native) {
258
261
  this.#native = native;
262
+ (0, runtime_handles_js_1.registerRustDatabaseHandle)(this, native);
259
263
  }
260
264
  static connect(nativeOrAddress, addressOrDatabase, databaseOrOptions = {}, maybeOptions = {}) {
261
265
  const parsed = parseConnectArguments(nativeOrAddress, addressOrDatabase, databaseOrOptions, maybeOptions);
@@ -294,6 +298,7 @@ class RustTransactionContext {
294
298
  #native;
295
299
  constructor(native) {
296
300
  this.#native = native;
301
+ (0, runtime_handles_js_1.registerRustTransactionHandle)(this, native);
297
302
  }
298
303
  query(query) {
299
304
  return parseJson(this.#native.queryJson(query));