Separate command descriptors from invocations
This commit is contained in:
parent
79e5121120
commit
80dae63a57
44 changed files with 438 additions and 86 deletions
|
|
@ -35,7 +35,7 @@ export type EveSurfaceStyles = {
|
|||
}>;
|
||||
export interface EveCommandIntent {
|
||||
type: "surface-command";
|
||||
schema: "gamecult.eve.command.v1";
|
||||
schema: "gamecult.eve.command_invocation.v1";
|
||||
providerId: string;
|
||||
surfaceId: string;
|
||||
command: string;
|
||||
|
|
|
|||
2
packages/eve-browser-lowering/dist/index.js
vendored
2
packages/eve-browser-lowering/dist/index.js
vendored
|
|
@ -1847,7 +1847,7 @@ export function createEveCommandIntent(commandId, props = {}, options = currentO
|
|||
const receiptSchema = firstString(worldInteraction.receiptSchema, props.receiptSchema, action.receiptSchema);
|
||||
const intent = {
|
||||
type: "surface-command",
|
||||
schema: "gamecult.eve.command.v1",
|
||||
schema: "gamecult.eve.command_invocation.v1",
|
||||
providerId,
|
||||
surfaceId,
|
||||
command: commandId || stringProp(action.type, "invoke"),
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export type EveSurfaceStyles =
|
|||
|
||||
export interface EveCommandIntent {
|
||||
type: "surface-command";
|
||||
schema: "gamecult.eve.command.v1";
|
||||
schema: "gamecult.eve.command_invocation.v1";
|
||||
providerId: string;
|
||||
surfaceId: string;
|
||||
command: string;
|
||||
|
|
@ -2200,7 +2200,7 @@ export function createEveCommandIntent(
|
|||
const receiptSchema = firstString(worldInteraction.receiptSchema, props.receiptSchema, action.receiptSchema);
|
||||
const intent: EveCommandIntent = {
|
||||
type: "surface-command",
|
||||
schema: "gamecult.eve.command.v1",
|
||||
schema: "gamecult.eve.command_invocation.v1",
|
||||
providerId,
|
||||
surfaceId,
|
||||
command: commandId || stringProp(action.type, "invoke"),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,261 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GameCult.Caching;
|
||||
using MessagePack;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace GameCult.Eve.Surface
|
||||
{
|
||||
[CultDocument("gamecult.eve.provider_advertisement", SchemaId)]
|
||||
[MessagePackObject]
|
||||
public sealed class EveProviderAdvertisementDocument
|
||||
{
|
||||
public const string SchemaId = "gamecult.eve.provider_advertisement.v1";
|
||||
|
||||
public EveProviderAdvertisementDocument(
|
||||
string providerId,
|
||||
string serviceId,
|
||||
string verseId,
|
||||
string title,
|
||||
string kind,
|
||||
string cultMeshAddress,
|
||||
string updatedAtUtc,
|
||||
EveProviderFreshness freshness,
|
||||
IReadOnlyList<string> schemas,
|
||||
IReadOnlyList<EveProviderWitness> witnesses,
|
||||
IReadOnlyList<EveAdvertisedSurface> surfaces,
|
||||
IReadOnlyList<EveAdvertisedCommand> commands)
|
||||
: this(SchemaId, providerId, serviceId, verseId, title, kind, cultMeshAddress, updatedAtUtc, freshness, schemas, witnesses, surfaces, commands)
|
||||
{
|
||||
}
|
||||
|
||||
[SerializationConstructor]
|
||||
public EveProviderAdvertisementDocument(
|
||||
string schema,
|
||||
string providerId,
|
||||
string serviceId,
|
||||
string verseId,
|
||||
string title,
|
||||
string kind,
|
||||
string cultMeshAddress,
|
||||
string updatedAtUtc,
|
||||
EveProviderFreshness freshness,
|
||||
IReadOnlyList<string> schemas,
|
||||
IReadOnlyList<EveProviderWitness> witnesses,
|
||||
IReadOnlyList<EveAdvertisedSurface> surfaces,
|
||||
IReadOnlyList<EveAdvertisedCommand> commands)
|
||||
{
|
||||
Schema = string.IsNullOrWhiteSpace(schema) ? SchemaId : schema;
|
||||
ProviderId = providerId ?? "";
|
||||
ServiceId = serviceId ?? "";
|
||||
VerseId = verseId ?? "";
|
||||
Title = title ?? "";
|
||||
Kind = kind ?? "";
|
||||
CultMeshAddress = cultMeshAddress ?? "";
|
||||
UpdatedAtUtc = updatedAtUtc ?? "";
|
||||
Freshness = freshness ?? new EveProviderFreshness("unknown", "", 0);
|
||||
Schemas = schemas ?? Array.Empty<string>();
|
||||
Witnesses = witnesses ?? Array.Empty<EveProviderWitness>();
|
||||
Surfaces = surfaces ?? Array.Empty<EveAdvertisedSurface>();
|
||||
Commands = commands ?? Array.Empty<EveAdvertisedCommand>();
|
||||
}
|
||||
|
||||
[Key(0)] public string Schema { get; }
|
||||
[Key(1)] public string ProviderId { get; }
|
||||
[Key(2)] public string ServiceId { get; }
|
||||
[Key(3)] public string VerseId { get; }
|
||||
[Key(4)] public string Title { get; }
|
||||
[Key(5)] public string Kind { get; }
|
||||
[Key(6)] public string CultMeshAddress { get; }
|
||||
[Key(7)] public string UpdatedAtUtc { get; }
|
||||
[Key(8)] public EveProviderFreshness Freshness { get; }
|
||||
[Key(9)] public IReadOnlyList<string> Schemas { get; }
|
||||
[Key(10)] public IReadOnlyList<EveProviderWitness> Witnesses { get; }
|
||||
[Key(11)] public IReadOnlyList<EveAdvertisedSurface> Surfaces { get; }
|
||||
[Key(12)] public IReadOnlyList<EveAdvertisedCommand> Commands { get; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class EveProviderFreshness
|
||||
{
|
||||
[SerializationConstructor]
|
||||
public EveProviderFreshness(string state, string lastSeenAtUtc, long maxAgeMs)
|
||||
{
|
||||
State = state ?? "";
|
||||
LastSeenAtUtc = lastSeenAtUtc ?? "";
|
||||
MaxAgeMs = maxAgeMs;
|
||||
}
|
||||
|
||||
[Key(0)] public string State { get; }
|
||||
[Key(1)] public string LastSeenAtUtc { get; }
|
||||
[Key(2)] public long MaxAgeMs { get; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class EveProviderWitness
|
||||
{
|
||||
[SerializationConstructor]
|
||||
public EveProviderWitness(string kind, string reference, string summary)
|
||||
{
|
||||
Kind = kind ?? "";
|
||||
Reference = reference ?? "";
|
||||
Summary = summary ?? "";
|
||||
}
|
||||
|
||||
[Key(0)] public string Kind { get; }
|
||||
[Key(1)] public string Reference { get; }
|
||||
[Key(2)] public string Summary { get; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class EveAdvertisedSurface
|
||||
{
|
||||
[SerializationConstructor]
|
||||
public EveAdvertisedSurface(
|
||||
string surfaceId,
|
||||
string schema,
|
||||
string recordRef,
|
||||
string transport,
|
||||
string status,
|
||||
string surfaceKind,
|
||||
EveWorldInteractionAdvertisement? worldInteraction = null)
|
||||
{
|
||||
SurfaceId = surfaceId ?? "";
|
||||
Schema = schema ?? "";
|
||||
RecordRef = recordRef ?? "";
|
||||
Transport = transport ?? "";
|
||||
Status = status ?? "";
|
||||
SurfaceKind = surfaceKind ?? "";
|
||||
WorldInteraction = worldInteraction;
|
||||
}
|
||||
|
||||
[Key(0)] public string SurfaceId { get; }
|
||||
[Key(1)] public string Schema { get; }
|
||||
[Key(2)] public string RecordRef { get; }
|
||||
[Key(3)] public string Transport { get; }
|
||||
[Key(4)] public string Status { get; }
|
||||
[Key(5)] public string SurfaceKind { get; }
|
||||
[Key(6)] public EveWorldInteractionAdvertisement? WorldInteraction { get; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class EveWorldInteractionAdvertisement
|
||||
{
|
||||
[SerializationConstructor]
|
||||
public EveWorldInteractionAdvertisement(
|
||||
string projectionKind,
|
||||
IReadOnlyList<string> stateSchemas,
|
||||
string commandBoundary,
|
||||
string commandRecordRef,
|
||||
string receiptSchema,
|
||||
string receiptRecordRef,
|
||||
string assetManifestRecordRef,
|
||||
IReadOnlyList<string> loweringTargets,
|
||||
string ownership)
|
||||
{
|
||||
ProjectionKind = projectionKind ?? "";
|
||||
StateSchemas = stateSchemas ?? Array.Empty<string>();
|
||||
CommandBoundary = commandBoundary ?? "";
|
||||
CommandRecordRef = commandRecordRef ?? "";
|
||||
ReceiptSchema = receiptSchema ?? "";
|
||||
ReceiptRecordRef = receiptRecordRef ?? "";
|
||||
AssetManifestRecordRef = assetManifestRecordRef ?? "";
|
||||
LoweringTargets = loweringTargets ?? Array.Empty<string>();
|
||||
Ownership = ownership ?? "";
|
||||
}
|
||||
|
||||
[Key(0)] public string ProjectionKind { get; }
|
||||
[Key(1)] public IReadOnlyList<string> StateSchemas { get; }
|
||||
[Key(2)] public string CommandBoundary { get; }
|
||||
[Key(3)] public string CommandRecordRef { get; }
|
||||
[Key(4)] public string ReceiptSchema { get; }
|
||||
[Key(5)] public string ReceiptRecordRef { get; }
|
||||
[Key(6)] public string AssetManifestRecordRef { get; }
|
||||
[Key(7)] public IReadOnlyList<string> LoweringTargets { get; }
|
||||
[Key(8)] public string Ownership { get; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class EveAdvertisedCommand
|
||||
{
|
||||
[SerializationConstructor]
|
||||
public EveAdvertisedCommand(string command, string surfaceId, string transport, string summary)
|
||||
{
|
||||
Command = command ?? "";
|
||||
SurfaceId = surfaceId ?? "";
|
||||
Transport = transport ?? "";
|
||||
Summary = summary ?? "";
|
||||
}
|
||||
|
||||
[Key(0)] public string Command { get; }
|
||||
[Key(1)] public string SurfaceId { get; }
|
||||
[Key(2)] public string Transport { get; }
|
||||
[Key(3)] public string Summary { get; }
|
||||
}
|
||||
|
||||
[CultDocument("gamecult.eve.command_receipt", SchemaId)]
|
||||
[MessagePackObject]
|
||||
public sealed class EveCommandReceiptDocument
|
||||
{
|
||||
public const string SchemaId = "gamecult.eve.command_receipt.v1";
|
||||
|
||||
public EveCommandReceiptDocument(
|
||||
string receiptId,
|
||||
string commandId,
|
||||
string command,
|
||||
string state,
|
||||
string ownerRepo,
|
||||
string authority,
|
||||
string providerId,
|
||||
string surfaceId,
|
||||
string message,
|
||||
string issuedAtUtc,
|
||||
long sourceVersion)
|
||||
: this(SchemaId, receiptId, commandId, command, state, ownerRepo, authority, providerId, surfaceId, message, issuedAtUtc, sourceVersion)
|
||||
{
|
||||
}
|
||||
|
||||
[SerializationConstructor]
|
||||
public EveCommandReceiptDocument(
|
||||
string schema,
|
||||
string receiptId,
|
||||
string commandId,
|
||||
string command,
|
||||
string state,
|
||||
string ownerRepo,
|
||||
string authority,
|
||||
string providerId,
|
||||
string surfaceId,
|
||||
string message,
|
||||
string issuedAtUtc,
|
||||
long sourceVersion)
|
||||
{
|
||||
Schema = string.IsNullOrWhiteSpace(schema) ? SchemaId : schema;
|
||||
ReceiptId = receiptId ?? "";
|
||||
CommandId = commandId ?? "";
|
||||
Command = command ?? "";
|
||||
State = state ?? "";
|
||||
OwnerRepo = ownerRepo ?? "";
|
||||
Authority = authority ?? "";
|
||||
ProviderId = providerId ?? "";
|
||||
SurfaceId = surfaceId ?? "";
|
||||
Message = message ?? "";
|
||||
IssuedAtUtc = issuedAtUtc ?? "";
|
||||
SourceVersion = sourceVersion;
|
||||
}
|
||||
|
||||
[Key(0)] public string Schema { get; }
|
||||
[Key(1)] public string ReceiptId { get; }
|
||||
[Key(2)] public string CommandId { get; }
|
||||
[Key(3)] public string Command { get; }
|
||||
[Key(4)] public string State { get; }
|
||||
[Key(5)] public string OwnerRepo { get; }
|
||||
[Key(6)] public string Authority { get; }
|
||||
[Key(7)] public string ProviderId { get; }
|
||||
[Key(8)] public string SurfaceId { get; }
|
||||
[Key(9)] public string Message { get; }
|
||||
[Key(10)] public string IssuedAtUtc { get; }
|
||||
[Key(11)] public long SourceVersion { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f7ea0cd07c4d5da4099b5acf8d44ca2e
|
||||
|
|
@ -269,9 +269,11 @@ namespace GameCult.Eve.Surface
|
|||
public string Transport => Operation.RouteHint.Description ?? "";
|
||||
}
|
||||
|
||||
[CultDocument("gamecult.eve.command", SchemaId)]
|
||||
[MessagePackObject]
|
||||
public sealed class EveSurfaceCommandRequest
|
||||
{
|
||||
public const string SchemaId = "gamecult.eve.command.v1";
|
||||
public const string SchemaId = "gamecult.eve.command_invocation.v1";
|
||||
|
||||
public EveSurfaceCommandRequest(
|
||||
string providerId,
|
||||
|
|
@ -282,7 +284,23 @@ namespace GameCult.Eve.Surface
|
|||
string clientId,
|
||||
string commandBoundary = "",
|
||||
string receiptSchema = "")
|
||||
: this(SchemaId, providerId, surfaceId, operation, payload, issuedAt, clientId, commandBoundary, receiptSchema)
|
||||
{
|
||||
}
|
||||
|
||||
[SerializationConstructor]
|
||||
public EveSurfaceCommandRequest(
|
||||
string schema,
|
||||
string providerId,
|
||||
string surfaceId,
|
||||
CultMeshOperationInvocationDescriptor operation,
|
||||
CultMeshOperationPayload payload,
|
||||
DateTimeOffset issuedAt,
|
||||
string clientId,
|
||||
string commandBoundary,
|
||||
string receiptSchema)
|
||||
{
|
||||
Schema = string.IsNullOrWhiteSpace(schema) ? SchemaId : schema;
|
||||
ProviderId = providerId;
|
||||
SurfaceId = surfaceId;
|
||||
Operation = operation ?? throw new ArgumentNullException(nameof(operation));
|
||||
|
|
@ -293,24 +311,37 @@ namespace GameCult.Eve.Surface
|
|||
ReceiptSchema = receiptSchema ?? "";
|
||||
}
|
||||
|
||||
public string Schema => SchemaId;
|
||||
[Key(0)]
|
||||
public string Schema { get; }
|
||||
|
||||
[Key(1)]
|
||||
public string ProviderId { get; }
|
||||
|
||||
[Key(2)]
|
||||
public string SurfaceId { get; }
|
||||
|
||||
[Key(3)]
|
||||
public CultMeshOperationInvocationDescriptor Operation { get; }
|
||||
|
||||
[IgnoreMember]
|
||||
public string Command => Operation.OperationId;
|
||||
|
||||
[Key(4)]
|
||||
public CultMeshOperationPayload Payload { get; }
|
||||
|
||||
[Key(5)]
|
||||
public DateTimeOffset IssuedAt { get; }
|
||||
|
||||
[Key(6)]
|
||||
public string ClientId { get; }
|
||||
|
||||
[Key(7)]
|
||||
public string CommandBoundary { get; }
|
||||
|
||||
[Key(8)]
|
||||
public string ReceiptSchema { get; }
|
||||
|
||||
[IgnoreMember]
|
||||
public string CommandId => Operation.IdempotencyKey ?? "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
],
|
||||
"unsupportedPlugins": [],
|
||||
"commandTransport": {
|
||||
"schema": "gamecult.eve.command.v1",
|
||||
"schema": "gamecult.eve.command_invocation.v1",
|
||||
"emitter": "EveUiToolkitSurfaceLowerer.EmitCommand",
|
||||
"clientId": "unity-uitoolkit"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@
|
|||
"contractInputs": [
|
||||
"gamecult.eve.surface.v1",
|
||||
"gamecult.eve.command.v1",
|
||||
"gamecult.eve.command_invocation.v1",
|
||||
"gamecult.eve.provider_advertisement.v1",
|
||||
"gamecult.eve.plugin_advertisement.v1",
|
||||
"gamecult.eve.plugin.v1",
|
||||
|
|
|
|||
Loading…
Reference in a new issue