@irtio/schema 0.11.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +14 -1
- package/dist/index.js +12 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -418,6 +418,12 @@ declare function client<P extends Fields = {}, R extends Fields = Fields>(spec:
|
|
|
418
418
|
}): RpcDef<'client', P, R>;
|
|
419
419
|
/** RPC names a builder may not declare (built-ins live in `@irtio/protocol`). */
|
|
420
420
|
declare const RESERVED_RPC_NAMES: readonly string[];
|
|
421
|
+
/**
|
|
422
|
+
* The prefix irtio's built-in RPC names carry (`$ownership.ask`), refused to a builder here and to
|
|
423
|
+
* a caller in `@irtio/protocol`'s `isReservedRpcName`. Stated twice because the dependency runs
|
|
424
|
+
* schema → protocol and never the other way.
|
|
425
|
+
*/
|
|
426
|
+
declare const RESERVED_RPC_PREFIX = "$";
|
|
421
427
|
/** Collection names a builder may not declare (the runtime merges built-in state under them). */
|
|
422
428
|
declare const RESERVED_COLLECTION_NAMES: readonly string[];
|
|
423
429
|
interface FieldDesc {
|
|
@@ -1110,5 +1116,12 @@ interface SchemaChange {
|
|
|
1110
1116
|
}
|
|
1111
1117
|
/** Compares two compiled schemas and returns every classified change, sorted by path then code. */
|
|
1112
1118
|
declare function diffSchemas(oldSchema: AnySchema, newSchema: AnySchema): SchemaChange[];
|
|
1119
|
+
/**
|
|
1120
|
+
* True when every breaking change in `changes` lives under the RPC table (`rpc` / `rpc.*`
|
|
1121
|
+
* paths) and there is at least one. Such a change breaks connected clients (the version fence
|
|
1122
|
+
* reconnects them) but touches nothing a snapshot stores, so a deploy needs `--allow-breaking`
|
|
1123
|
+
* and no migration: a chain step without one decodes and re-encodes losslessly.
|
|
1124
|
+
*/
|
|
1125
|
+
declare function breakingIsWireOnly(changes: readonly SchemaChange[]): boolean;
|
|
1113
1126
|
|
|
1114
|
-
export { type AddOptions, type AnyDef, type AnyMessageMap, type AnyRpc, type AnySchema, type AnyType, type Body2dState, type BodyFieldsOf, type BroadcastProxy, ByteReader, ByteWriter, CANONICAL_VERSION, type ClientCallProxy, type ClientImplementations, type ClientRpcs, type ClientState, type Collection, type CollectionDesc, type CollectionDirty, type DecodedSnapshot, type DeepReadonly, type DeepWritable, type DefMap, type Delta, type DeltaCollection, type DeltaOp, type DirtySet, EntityCollection, type EntityDef, type EntityOptions, type EntityPhysics, type FieldDesc, type FieldMask, type Fields, type FromCanonicalOptions, type GridDesc, type GridOptions, type Header, ID_MAX_BYTES, type Implementations, type Infer, type InferFields, type InitFields, type InitOf, type InstanceOf, type Kind, MAX_MESSAGES, type MessageChannels, type MessageDesc, type MessageMap, type MessageNames, type MessageValue, type MessagesOf, type OwnableKeys, type Owned, type OwnershipDesc, type OwnershipLeave, type OwnershipLeaveAction, type OwnershipOptions, type OwnershipPosition, type OwnershipTransfer, PHYSICS_BODY_CHANNELS, type PhysicsBodyChannel, type PhysicsBodyMap, type PhysicsDesc, type PhysicsKeys, type PlainState, RESERVED_COLLECTION_NAMES, RESERVED_RPC_NAMES, type ReadonlyBodyFields, type ReadonlyCollection, type RecordDirty, type RoleOf, type RpcDef, type RpcDesc, type RpcDirection, type RpcMap, type RpcParams, type RpcReturns, type RpcSpec, SERVER_OWNER, SINGLETON_ID, type Schema, type SchemaChange, type SchemaDefs, type SchemaIssue, type SchemaMessages, type SchemaOptions, type SchemaRoles, type SchemaRpc, type ServerCallProxy, type ServerMessageChannels, type ServerOwnedKeys, type ServerRpcs, type SingletonDef, type SnapshotOptions, type State, type Tracked, type Type, type TypeDesc, type ValueSink, type Visibility, type VisibleKeys, type WalkEvents, angleFrom2d, applyChannel2d, applyDelta, bool, bytesEqual, canonicalOwnership, canonicalPhysics, canonicalType, channelOf2d, client, cloneValue, collectionDirty, compileOwnership, compilePhysics, computeDirty, createDirtySet, createFieldMask, createState, decodeDelta, decodeDeltaFrom, decodeFields, decodeSnapshot, defaultRecord, defaultValue, defineSchema, describeType, diffSchemas, encodeDelta, encodeFields, encodeSnapshot, entity, enumOf, estimateSize, f32, f64, filterDirty, frozenProxy, i32, isDirtyEmpty, isWhole, list, markAdd, markField, markOwner, markPath, markRemove, mergeDirty, mergeMask, normalizeRecord, normalizeValue, ownershipFromCanonical, parseHold, physicsFromCanonical, readValue, ref, schemaFromCanonical, server, sha256, sha256Hex, singleton, stableStringify, str, struct, toHex, track, u16, u32, u8, validateForDeploy, validateValue, walkDelta, walkSnapshot, writeValue };
|
|
1127
|
+
export { type AddOptions, type AnyDef, type AnyMessageMap, type AnyRpc, type AnySchema, type AnyType, type Body2dState, type BodyFieldsOf, type BroadcastProxy, ByteReader, ByteWriter, CANONICAL_VERSION, type ClientCallProxy, type ClientImplementations, type ClientRpcs, type ClientState, type Collection, type CollectionDesc, type CollectionDirty, type DecodedSnapshot, type DeepReadonly, type DeepWritable, type DefMap, type Delta, type DeltaCollection, type DeltaOp, type DirtySet, EntityCollection, type EntityDef, type EntityOptions, type EntityPhysics, type FieldDesc, type FieldMask, type Fields, type FromCanonicalOptions, type GridDesc, type GridOptions, type Header, ID_MAX_BYTES, type Implementations, type Infer, type InferFields, type InitFields, type InitOf, type InstanceOf, type Kind, MAX_MESSAGES, type MessageChannels, type MessageDesc, type MessageMap, type MessageNames, type MessageValue, type MessagesOf, type OwnableKeys, type Owned, type OwnershipDesc, type OwnershipLeave, type OwnershipLeaveAction, type OwnershipOptions, type OwnershipPosition, type OwnershipTransfer, PHYSICS_BODY_CHANNELS, type PhysicsBodyChannel, type PhysicsBodyMap, type PhysicsDesc, type PhysicsKeys, type PlainState, RESERVED_COLLECTION_NAMES, RESERVED_RPC_NAMES, RESERVED_RPC_PREFIX, type ReadonlyBodyFields, type ReadonlyCollection, type RecordDirty, type RoleOf, type RpcDef, type RpcDesc, type RpcDirection, type RpcMap, type RpcParams, type RpcReturns, type RpcSpec, SERVER_OWNER, SINGLETON_ID, type Schema, type SchemaChange, type SchemaDefs, type SchemaIssue, type SchemaMessages, type SchemaOptions, type SchemaRoles, type SchemaRpc, type ServerCallProxy, type ServerMessageChannels, type ServerOwnedKeys, type ServerRpcs, type SingletonDef, type SnapshotOptions, type State, type Tracked, type Type, type TypeDesc, type ValueSink, type Visibility, type VisibleKeys, type WalkEvents, angleFrom2d, applyChannel2d, applyDelta, bool, breakingIsWireOnly, bytesEqual, canonicalOwnership, canonicalPhysics, canonicalType, channelOf2d, client, cloneValue, collectionDirty, compileOwnership, compilePhysics, computeDirty, createDirtySet, createFieldMask, createState, decodeDelta, decodeDeltaFrom, decodeFields, decodeSnapshot, defaultRecord, defaultValue, defineSchema, describeType, diffSchemas, encodeDelta, encodeFields, encodeSnapshot, entity, enumOf, estimateSize, f32, f64, filterDirty, frozenProxy, i32, isDirtyEmpty, isWhole, list, markAdd, markField, markOwner, markPath, markRemove, mergeDirty, mergeMask, normalizeRecord, normalizeValue, ownershipFromCanonical, parseHold, physicsFromCanonical, readValue, ref, schemaFromCanonical, server, sha256, sha256Hex, singleton, stableStringify, str, struct, toHex, track, u16, u32, u8, validateForDeploy, validateValue, walkDelta, walkSnapshot, writeValue };
|
package/dist/index.js
CHANGED
|
@@ -676,6 +676,7 @@ function makeRpc(direction, spec) {
|
|
|
676
676
|
return { kind: "rpc", direction, params, returns: spec.returns };
|
|
677
677
|
}
|
|
678
678
|
var RESERVED_RPC_NAMES = ["requestOwnership"];
|
|
679
|
+
var RESERVED_RPC_PREFIX = "$";
|
|
679
680
|
var RESERVED_COLLECTION_NAMES = ["clients"];
|
|
680
681
|
var MAX_MESSAGES = 256;
|
|
681
682
|
function defineSchema(defs, options = {}) {
|
|
@@ -768,6 +769,11 @@ function defineSchema(defs, options = {}) {
|
|
|
768
769
|
if (RESERVED_RPC_NAMES.includes(n)) {
|
|
769
770
|
throw new Error(`RPC name ${JSON.stringify(n)} is reserved by irtio (built-in RPC)`);
|
|
770
771
|
}
|
|
772
|
+
if (n.startsWith(RESERVED_RPC_PREFIX)) {
|
|
773
|
+
throw new Error(
|
|
774
|
+
`RPC name ${JSON.stringify(n)} starts with ${JSON.stringify(RESERVED_RPC_PREFIX)}, which is reserved for irtio's built-in RPCs \u2014 pick another name`
|
|
775
|
+
);
|
|
776
|
+
}
|
|
771
777
|
}
|
|
772
778
|
const rpcs = Object.keys(rpcMap).sort().map((name, index) => {
|
|
773
779
|
const r = rpcMap[name];
|
|
@@ -2784,6 +2790,10 @@ function diffSchemas(oldSchema, newSchema) {
|
|
|
2784
2790
|
);
|
|
2785
2791
|
return changes;
|
|
2786
2792
|
}
|
|
2793
|
+
function breakingIsWireOnly(changes) {
|
|
2794
|
+
const breaking = changes.filter((c) => c.kind === "breaking");
|
|
2795
|
+
return breaking.length > 0 && breaking.every((c) => c.path === "rpc" || c.path.startsWith("rpc."));
|
|
2796
|
+
}
|
|
2787
2797
|
function diffCollections(oldCollections, newCollections, changes) {
|
|
2788
2798
|
const oldByName = new Map(oldCollections.map((c) => [c.name, c]));
|
|
2789
2799
|
const newByName = new Map(newCollections.map((c) => [c.name, c]));
|
|
@@ -3196,12 +3206,14 @@ export {
|
|
|
3196
3206
|
PHYSICS_BODY_CHANNELS,
|
|
3197
3207
|
RESERVED_COLLECTION_NAMES,
|
|
3198
3208
|
RESERVED_RPC_NAMES,
|
|
3209
|
+
RESERVED_RPC_PREFIX,
|
|
3199
3210
|
SERVER_OWNER,
|
|
3200
3211
|
SINGLETON_ID,
|
|
3201
3212
|
angleFrom2d,
|
|
3202
3213
|
applyChannel2d,
|
|
3203
3214
|
applyDelta,
|
|
3204
3215
|
bool,
|
|
3216
|
+
breakingIsWireOnly,
|
|
3205
3217
|
bytesEqual,
|
|
3206
3218
|
canonicalOwnership,
|
|
3207
3219
|
canonicalPhysics,
|