@arcforges/proto 1.0.0-ci.101.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +62 -0
- package/README.md +34 -0
- package/build-identity.json +106 -0
- package/contracts.binpb +0 -0
- package/dist/gen/arcforges/events/v1/events_pb.d.ts +22 -0
- package/dist/gen/arcforges/events/v1/events_pb.js +13 -0
- package/dist/gen/arcforges/foundation/v1/foundation_pb.d.ts +986 -0
- package/dist/gen/arcforges/foundation/v1/foundation_pb.js +308 -0
- package/dist/gen/arcforges/hello/v1/hello_pb.d.ts +51 -0
- package/dist/gen/arcforges/hello/v1/hello_pb.js +24 -0
- package/dist/gen/arcforges/publicapi/v1/content_pb.d.ts +4398 -0
- package/dist/gen/arcforges/publicapi/v1/content_pb.js +789 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +10 -0
- package/dist/services/gen/catalog.d.ts +8 -0
- package/dist/services/gen/catalog.js +6 -0
- package/dist/shapes/gen/proto.d.ts +149 -0
- package/dist/shapes/gen/proto.js +9140 -0
- package/dist/values/gen/identifiers.d.ts +79 -0
- package/dist/values/gen/identifiers.js +22 -0
- package/dist/values.d.ts +56 -0
- package/dist/values.js +178 -0
- package/dist/wire.d.ts +34 -0
- package/dist/wire.js +49 -0
- package/package.json +47 -0
- package/sbom.cdx.json +45 -0
- package/schemas/public/proto/arcforges/events/v1/events.proto +14 -0
- package/schemas/public/proto/arcforges/foundation/v1/foundation.proto +248 -0
- package/schemas/public/proto/arcforges/hello/v1/hello.proto +23 -0
- package/schemas/public/proto/arcforges/publicapi/v1/content.proto +1200 -0
- package/source.json +35 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Id } from "../../gen/arcforges/foundation/v1/foundation_pb.js";
|
|
2
|
+
declare const identifierBrand: unique symbol;
|
|
3
|
+
export type IdentifierDomain = "RealmId" | "UserId" | "WorkspaceId" | "DeviceId" | "InstallationId" | "InstanceId" | "CommandId" | "CorrelationId" | "ResourceId" | "BlobId" | "ArtifactId" | "ContentOriginId" | "ContentUnitId" | "ConflictId" | "DelegationId" | "TaskId" | "RunId" | "StepId" | "AttemptId" | "InvocationId" | "ApprovalId" | "AutomationId" | "ConversationId" | "BranchId" | "MessageId" | "ProjectId" | "AgentProfileId" | "SkillId" | "FolderId" | "DocumentId" | "BlockId" | "NotebookId" | "TagId" | "PropertyDefId" | "ViewId" | "SessionRecordId" | "CaptureId" | "SegmentId" | "ChannelId" | "FindingId" | "SequenceId" | "TrackId" | "TimelineItemId" | "MediaAssetId" | "EffectInstanceId" | "SlateProjectId" | "ChatTurnId" | "ExecutionStreamId" | "ProductJobId" | "ToolProposalId" | "MemoryId" | "PreferenceId" | "GrantId" | "InlineId" | "TextRunId" | "TableRowId" | "TableCellId" | "SelectOptionId" | "ScopeConfigurationId" | "ScopeProjectId" | "ScopeAnnotationId" | "ScopeEventId" | "SelectionId" | "SourceConsentId" | "MediaBinId" | "TimelineGroupId" | "TimelineLinkGroupId" | "TimelineMarkerId" | "TransitionId";
|
|
4
|
+
export type DomainId<T extends IdentifierDomain> = string & {
|
|
5
|
+
readonly [identifierBrand]: T;
|
|
6
|
+
};
|
|
7
|
+
export declare function parseId<T extends IdentifierDomain>(domain: T, value: string): DomainId<T>;
|
|
8
|
+
export declare function idFromWire<T extends IdentifierDomain>(domain: T, value: Id): DomainId<T>;
|
|
9
|
+
export declare function idToWire<T extends IdentifierDomain>(domain: T, value: DomainId<NoInfer<T>>): Id;
|
|
10
|
+
export type RealmId = DomainId<"RealmId">;
|
|
11
|
+
export type UserId = DomainId<"UserId">;
|
|
12
|
+
export type WorkspaceId = DomainId<"WorkspaceId">;
|
|
13
|
+
export type DeviceId = DomainId<"DeviceId">;
|
|
14
|
+
export type InstallationId = DomainId<"InstallationId">;
|
|
15
|
+
export type InstanceId = DomainId<"InstanceId">;
|
|
16
|
+
export type CommandId = DomainId<"CommandId">;
|
|
17
|
+
export type CorrelationId = DomainId<"CorrelationId">;
|
|
18
|
+
export type ResourceId = DomainId<"ResourceId">;
|
|
19
|
+
export type BlobId = DomainId<"BlobId">;
|
|
20
|
+
export type ArtifactId = DomainId<"ArtifactId">;
|
|
21
|
+
export type ContentOriginId = DomainId<"ContentOriginId">;
|
|
22
|
+
export type ContentUnitId = DomainId<"ContentUnitId">;
|
|
23
|
+
export type ConflictId = DomainId<"ConflictId">;
|
|
24
|
+
export type DelegationId = DomainId<"DelegationId">;
|
|
25
|
+
export type TaskId = DomainId<"TaskId">;
|
|
26
|
+
export type RunId = DomainId<"RunId">;
|
|
27
|
+
export type StepId = DomainId<"StepId">;
|
|
28
|
+
export type AttemptId = DomainId<"AttemptId">;
|
|
29
|
+
export type InvocationId = DomainId<"InvocationId">;
|
|
30
|
+
export type ApprovalId = DomainId<"ApprovalId">;
|
|
31
|
+
export type AutomationId = DomainId<"AutomationId">;
|
|
32
|
+
export type ConversationId = DomainId<"ConversationId">;
|
|
33
|
+
export type BranchId = DomainId<"BranchId">;
|
|
34
|
+
export type MessageId = DomainId<"MessageId">;
|
|
35
|
+
export type ProjectId = DomainId<"ProjectId">;
|
|
36
|
+
export type AgentProfileId = DomainId<"AgentProfileId">;
|
|
37
|
+
export type SkillId = DomainId<"SkillId">;
|
|
38
|
+
export type FolderId = DomainId<"FolderId">;
|
|
39
|
+
export type DocumentId = DomainId<"DocumentId">;
|
|
40
|
+
export type BlockId = DomainId<"BlockId">;
|
|
41
|
+
export type NotebookId = DomainId<"NotebookId">;
|
|
42
|
+
export type TagId = DomainId<"TagId">;
|
|
43
|
+
export type PropertyDefId = DomainId<"PropertyDefId">;
|
|
44
|
+
export type ViewId = DomainId<"ViewId">;
|
|
45
|
+
export type SessionRecordId = DomainId<"SessionRecordId">;
|
|
46
|
+
export type CaptureId = DomainId<"CaptureId">;
|
|
47
|
+
export type SegmentId = DomainId<"SegmentId">;
|
|
48
|
+
export type ChannelId = DomainId<"ChannelId">;
|
|
49
|
+
export type FindingId = DomainId<"FindingId">;
|
|
50
|
+
export type SequenceId = DomainId<"SequenceId">;
|
|
51
|
+
export type TrackId = DomainId<"TrackId">;
|
|
52
|
+
export type TimelineItemId = DomainId<"TimelineItemId">;
|
|
53
|
+
export type MediaAssetId = DomainId<"MediaAssetId">;
|
|
54
|
+
export type EffectInstanceId = DomainId<"EffectInstanceId">;
|
|
55
|
+
export type SlateProjectId = DomainId<"SlateProjectId">;
|
|
56
|
+
export type ChatTurnId = DomainId<"ChatTurnId">;
|
|
57
|
+
export type ExecutionStreamId = DomainId<"ExecutionStreamId">;
|
|
58
|
+
export type ProductJobId = DomainId<"ProductJobId">;
|
|
59
|
+
export type ToolProposalId = DomainId<"ToolProposalId">;
|
|
60
|
+
export type MemoryId = DomainId<"MemoryId">;
|
|
61
|
+
export type PreferenceId = DomainId<"PreferenceId">;
|
|
62
|
+
export type GrantId = DomainId<"GrantId">;
|
|
63
|
+
export type InlineId = DomainId<"InlineId">;
|
|
64
|
+
export type TextRunId = DomainId<"TextRunId">;
|
|
65
|
+
export type TableRowId = DomainId<"TableRowId">;
|
|
66
|
+
export type TableCellId = DomainId<"TableCellId">;
|
|
67
|
+
export type SelectOptionId = DomainId<"SelectOptionId">;
|
|
68
|
+
export type ScopeConfigurationId = DomainId<"ScopeConfigurationId">;
|
|
69
|
+
export type ScopeProjectId = DomainId<"ScopeProjectId">;
|
|
70
|
+
export type ScopeAnnotationId = DomainId<"ScopeAnnotationId">;
|
|
71
|
+
export type ScopeEventId = DomainId<"ScopeEventId">;
|
|
72
|
+
export type SelectionId = DomainId<"SelectionId">;
|
|
73
|
+
export type SourceConsentId = DomainId<"SourceConsentId">;
|
|
74
|
+
export type MediaBinId = DomainId<"MediaBinId">;
|
|
75
|
+
export type TimelineGroupId = DomainId<"TimelineGroupId">;
|
|
76
|
+
export type TimelineLinkGroupId = DomainId<"TimelineLinkGroupId">;
|
|
77
|
+
export type TimelineMarkerId = DomainId<"TimelineMarkerId">;
|
|
78
|
+
export type TransitionId = DomainId<"TransitionId">;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// <auto-generated />
|
|
3
|
+
// Generated by eng/generate_shapes.py; do not edit.
|
|
4
|
+
import { create } from "@bufbuild/protobuf";
|
|
5
|
+
import { IdSchema } from "../../gen/arcforges/foundation/v1/foundation_pb.js";
|
|
6
|
+
export function parseId(domain, value) {
|
|
7
|
+
if (typeof domain !== 'string' || !identifierDomains.has(domain) || typeof value !== 'string' || /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.exec(value)?.[0] !== value || value === '00000000-0000-0000-0000-000000000000')
|
|
8
|
+
throw new TypeError('Invalid canonical domain identity');
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
export function idFromWire(domain, value) {
|
|
12
|
+
if (!(value?.value instanceof Uint8Array) || value.value.length !== 16 || !value.value.some(v => v !== 0))
|
|
13
|
+
throw new TypeError('Invalid wire UUID');
|
|
14
|
+
const h = Array.from(value.value, v => v.toString(16).padStart(2, '0')).join('');
|
|
15
|
+
return parseId(domain, `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20)}`);
|
|
16
|
+
}
|
|
17
|
+
export function idToWire(domain, value) {
|
|
18
|
+
const digits = parseId(domain, value).replaceAll('-', '');
|
|
19
|
+
const bytes = Uint8Array.from({ length: 16 }, (_, i) => Number.parseInt(digits.slice(i * 2, i * 2 + 2), 16));
|
|
20
|
+
return create(IdSchema, { value: bytes });
|
|
21
|
+
}
|
|
22
|
+
const identifierDomains = new Set(["RealmId", "UserId", "WorkspaceId", "DeviceId", "InstallationId", "InstanceId", "CommandId", "CorrelationId", "ResourceId", "BlobId", "ArtifactId", "ContentOriginId", "ContentUnitId", "ConflictId", "DelegationId", "TaskId", "RunId", "StepId", "AttemptId", "InvocationId", "ApprovalId", "AutomationId", "ConversationId", "BranchId", "MessageId", "ProjectId", "AgentProfileId", "SkillId", "FolderId", "DocumentId", "BlockId", "NotebookId", "TagId", "PropertyDefId", "ViewId", "SessionRecordId", "CaptureId", "SegmentId", "ChannelId", "FindingId", "SequenceId", "TrackId", "TimelineItemId", "MediaAssetId", "EffectInstanceId", "SlateProjectId", "ChatTurnId", "ExecutionStreamId", "ProductJobId", "ToolProposalId", "MemoryId", "PreferenceId", "GrantId", "InlineId", "TextRunId", "TableRowId", "TableCellId", "SelectOptionId", "ScopeConfigurationId", "ScopeProjectId", "ScopeAnnotationId", "ScopeEventId", "SelectionId", "SourceConsentId", "MediaBinId", "TimelineGroupId", "TimelineLinkGroupId", "TimelineMarkerId", "TransitionId"]);
|
package/dist/values.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { DescMessage, MessageShape } from "@bufbuild/protobuf";
|
|
2
|
+
import type { Revision, NativeContentRev, LocalNotesVersion, Decimal } from "./gen/arcforges/foundation/v1/foundation_pb.js";
|
|
3
|
+
export * from "./values/gen/identifiers.js";
|
|
4
|
+
declare const valueBrand: unique symbol;
|
|
5
|
+
type Branded<T, Name extends string> = T & {
|
|
6
|
+
readonly [valueBrand]: Name;
|
|
7
|
+
};
|
|
8
|
+
export type CloudRevision = Branded<bigint, "CloudRevision">;
|
|
9
|
+
export type NativeRevision = Branded<bigint, "NativeRevision">;
|
|
10
|
+
export type DeliverySequence = Branded<bigint, "DeliverySequence">;
|
|
11
|
+
export type OpaqueCursor = Branded<string, "OpaqueCursor">;
|
|
12
|
+
export type ExactDecimal = Branded<string, "ExactDecimal">;
|
|
13
|
+
export type LocalNotesToken = Readonly<{
|
|
14
|
+
acknowledgedRevision: bigint;
|
|
15
|
+
headLocalSequence: bigint;
|
|
16
|
+
}> & {
|
|
17
|
+
readonly [valueBrand]: "LocalNotesToken";
|
|
18
|
+
};
|
|
19
|
+
export declare function parseInt64(value: string): bigint;
|
|
20
|
+
export declare function parseUInt64(value: string): bigint;
|
|
21
|
+
export declare function cloudRevision(value: bigint): CloudRevision;
|
|
22
|
+
export declare function cloudRevisionFromWire(value: Revision): CloudRevision;
|
|
23
|
+
export declare function cloudRevisionToWire(value: CloudRevision): Revision;
|
|
24
|
+
export declare function newRootPrecondition(): Revision;
|
|
25
|
+
export declare function nativeRevision(value: bigint): NativeRevision;
|
|
26
|
+
export declare function nativeRevisionFromWire(value: NativeContentRev): NativeRevision;
|
|
27
|
+
export declare function nativeRevisionToWire(value: NativeRevision): NativeContentRev;
|
|
28
|
+
export declare function deliverySequence(value: bigint): DeliverySequence;
|
|
29
|
+
export declare function localNotesToken(acknowledgedRevision: bigint, headLocalSequence: bigint): LocalNotesToken;
|
|
30
|
+
export declare function localNotesFromWire(value: LocalNotesVersion): LocalNotesToken;
|
|
31
|
+
export declare function localNotesToWire(value: LocalNotesToken): LocalNotesVersion;
|
|
32
|
+
export declare function opaqueCursor(value: string): OpaqueCursor;
|
|
33
|
+
export declare function exactDecimal(value: string): ExactDecimal;
|
|
34
|
+
export declare function notesDecimal(value: string): ExactDecimal;
|
|
35
|
+
export declare function decimalFromWire(value: Decimal): ExactDecimal;
|
|
36
|
+
export declare function decimalToWire(value: ExactDecimal): Decimal;
|
|
37
|
+
export declare function decimalParts(value: ExactDecimal): Readonly<{
|
|
38
|
+
coefficient: bigint;
|
|
39
|
+
scale: number;
|
|
40
|
+
}>;
|
|
41
|
+
export declare function decimalFromCoefficient(coefficient: bigint, scale: number): ExactDecimal;
|
|
42
|
+
/** Decodes compatible read data, retaining unknown fields; strict validation decides mutation suitability. */
|
|
43
|
+
export declare function readProjection<T extends DescMessage>(schema: T, bytes: Uint8Array, validate: (value: unknown) => boolean): Readonly<{
|
|
44
|
+
message: MessageShape<T>;
|
|
45
|
+
knownProfile: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
/** Re-emits a generated projection, including its inert unknown fields. */
|
|
48
|
+
export declare function preserveProjection<T extends DescMessage>(schema: T, message: MessageShape<T>): Uint8Array;
|
|
49
|
+
export type RationalValue = Readonly<{
|
|
50
|
+
numerator: bigint;
|
|
51
|
+
denominator: bigint;
|
|
52
|
+
}> & {
|
|
53
|
+
readonly [valueBrand]: "RationalValue";
|
|
54
|
+
};
|
|
55
|
+
export declare function rationalValue(numerator: bigint, denominator: bigint): RationalValue;
|
|
56
|
+
export declare function convertTicksExact(ticks: bigint, sourceRate: RationalValue, targetRate: RationalValue): bigint;
|
package/dist/values.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
|
|
3
|
+
import { RevisionSchema, NativeContentRevSchema, LocalNotesVersionSchema, DecimalSchema, } from "./gen/arcforges/foundation/v1/foundation_pb.js";
|
|
4
|
+
export * from "./values/gen/identifiers.js";
|
|
5
|
+
const i64min = -9223372036854775808n;
|
|
6
|
+
const i64max = 9223372036854775807n;
|
|
7
|
+
const u64max = 18446744073709551615n;
|
|
8
|
+
export function parseInt64(value) {
|
|
9
|
+
if (typeof value !== "string" || /^(0|-?[1-9][0-9]*)$/.exec(value)?.[0] !== value)
|
|
10
|
+
throw new TypeError("Invalid canonical int64");
|
|
11
|
+
const result = BigInt(value);
|
|
12
|
+
if (result < i64min || result > i64max)
|
|
13
|
+
throw new RangeError("int64 overflow");
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
export function parseUInt64(value) {
|
|
17
|
+
if (typeof value !== "string" || /^(0|[1-9][0-9]*)$/.exec(value)?.[0] !== value)
|
|
18
|
+
throw new TypeError("Invalid canonical uint64");
|
|
19
|
+
const result = BigInt(value);
|
|
20
|
+
if (result > u64max)
|
|
21
|
+
throw new RangeError("uint64 overflow");
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
function unsigned(value) {
|
|
25
|
+
if (typeof value !== "bigint" || value < 0n || value > u64max)
|
|
26
|
+
throw new RangeError("Invalid uint64");
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
export function cloudRevision(value) {
|
|
30
|
+
if (typeof value !== "bigint" || value <= 0n || value > i64max)
|
|
31
|
+
throw new RangeError("Committed revision must be a positive int64");
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
export function cloudRevisionFromWire(value) {
|
|
35
|
+
return cloudRevision(value.value);
|
|
36
|
+
}
|
|
37
|
+
export function cloudRevisionToWire(value) {
|
|
38
|
+
return create(RevisionSchema, { value: cloudRevision(value) });
|
|
39
|
+
}
|
|
40
|
+
export function newRootPrecondition() {
|
|
41
|
+
return create(RevisionSchema, { value: 0n });
|
|
42
|
+
}
|
|
43
|
+
export function nativeRevision(value) {
|
|
44
|
+
return unsigned(value);
|
|
45
|
+
}
|
|
46
|
+
export function nativeRevisionFromWire(value) {
|
|
47
|
+
return nativeRevision(value.value);
|
|
48
|
+
}
|
|
49
|
+
export function nativeRevisionToWire(value) {
|
|
50
|
+
return create(NativeContentRevSchema, { value: nativeRevision(value) });
|
|
51
|
+
}
|
|
52
|
+
export function deliverySequence(value) {
|
|
53
|
+
return unsigned(value);
|
|
54
|
+
}
|
|
55
|
+
export function localNotesToken(acknowledgedRevision, headLocalSequence) {
|
|
56
|
+
if (typeof acknowledgedRevision !== "bigint" ||
|
|
57
|
+
acknowledgedRevision < 0n ||
|
|
58
|
+
acknowledgedRevision > i64max)
|
|
59
|
+
throw new RangeError("Invalid acknowledged revision");
|
|
60
|
+
return Object.freeze({
|
|
61
|
+
acknowledgedRevision,
|
|
62
|
+
headLocalSequence: unsigned(headLocalSequence),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export function localNotesFromWire(value) {
|
|
66
|
+
return localNotesToken(value.ackedRev?.value, value.headLocalSeq);
|
|
67
|
+
}
|
|
68
|
+
export function localNotesToWire(value) {
|
|
69
|
+
const checked = localNotesToken(value.acknowledgedRevision, value.headLocalSequence);
|
|
70
|
+
return create(LocalNotesVersionSchema, {
|
|
71
|
+
ackedRev: create(RevisionSchema, { value: checked.acknowledgedRevision }),
|
|
72
|
+
headLocalSeq: checked.headLocalSequence,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export function opaqueCursor(value) {
|
|
76
|
+
if (typeof value !== "string" || !validUnicode(value))
|
|
77
|
+
throw new TypeError("Invalid cursor Unicode");
|
|
78
|
+
let bytes = 0;
|
|
79
|
+
for (const scalar of value) {
|
|
80
|
+
const point = scalar.codePointAt(0);
|
|
81
|
+
bytes += point <= 0x7f ? 1 : point <= 0x7ff ? 2 : point <= 0xffff ? 3 : 4;
|
|
82
|
+
}
|
|
83
|
+
if (bytes > 4096)
|
|
84
|
+
throw new RangeError("Cursor too long");
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
export function exactDecimal(value) {
|
|
88
|
+
if (typeof value !== "string" ||
|
|
89
|
+
/^-?(0|[1-9][0-9]*)(\.[0-9]{1,9})?$/.exec(value)?.[0] !== value ||
|
|
90
|
+
(value.startsWith("-") && !/[1-9]/.test(value)) ||
|
|
91
|
+
value.replace(/[-.]/g, "").replace(/^0+/, "").length > 28)
|
|
92
|
+
throw new TypeError("Invalid exact decimal");
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
export function notesDecimal(value) {
|
|
96
|
+
const result = exactDecimal(value);
|
|
97
|
+
if (value.includes(".") && value.endsWith("0"))
|
|
98
|
+
throw new TypeError("Noncanonical Notes decimal");
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
export function decimalFromWire(value) {
|
|
102
|
+
return exactDecimal(value.value);
|
|
103
|
+
}
|
|
104
|
+
export function decimalToWire(value) {
|
|
105
|
+
return create(DecimalSchema, { value: exactDecimal(value) });
|
|
106
|
+
}
|
|
107
|
+
export function decimalParts(value) {
|
|
108
|
+
const checked = exactDecimal(value);
|
|
109
|
+
const point = checked.indexOf(".");
|
|
110
|
+
return Object.freeze({
|
|
111
|
+
coefficient: BigInt(checked.replace(".", "")),
|
|
112
|
+
scale: point < 0 ? 0 : checked.length - point - 1,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
export function decimalFromCoefficient(coefficient, scale) {
|
|
116
|
+
if (typeof coefficient !== "bigint" || !Number.isInteger(scale) || scale < 0 || scale > 9)
|
|
117
|
+
throw new RangeError("Invalid exact coefficient/scale");
|
|
118
|
+
const digits = (coefficient < 0n ? -coefficient : coefficient)
|
|
119
|
+
.toString()
|
|
120
|
+
.padStart(scale + 1, "0");
|
|
121
|
+
const value = scale === 0 ? digits : `${digits.slice(0, -scale)}.${digits.slice(-scale)}`;
|
|
122
|
+
return exactDecimal(coefficient < 0n ? `-${value}` : value);
|
|
123
|
+
}
|
|
124
|
+
/** Decodes compatible read data, retaining unknown fields; strict validation decides mutation suitability. */
|
|
125
|
+
export function readProjection(schema, bytes, validate) {
|
|
126
|
+
const message = fromBinary(schema, bytes);
|
|
127
|
+
return Object.freeze({ message, knownProfile: validate(message) });
|
|
128
|
+
}
|
|
129
|
+
/** Re-emits a generated projection, including its inert unknown fields. */
|
|
130
|
+
export function preserveProjection(schema, message) {
|
|
131
|
+
return toBinary(schema, message);
|
|
132
|
+
}
|
|
133
|
+
function validUnicode(text) {
|
|
134
|
+
for (let i = 0; i < text.length; i++) {
|
|
135
|
+
const first = text.charCodeAt(i);
|
|
136
|
+
if (first < 0xd800 || first > 0xdfff)
|
|
137
|
+
continue;
|
|
138
|
+
if (first > 0xdbff || ++i >= text.length)
|
|
139
|
+
return false;
|
|
140
|
+
const second = text.charCodeAt(i);
|
|
141
|
+
if (second < 0xdc00 || second > 0xdfff)
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
export function rationalValue(numerator, denominator) {
|
|
147
|
+
if (typeof numerator !== "bigint" ||
|
|
148
|
+
numerator < i64min ||
|
|
149
|
+
numerator > i64max ||
|
|
150
|
+
typeof denominator !== "bigint" ||
|
|
151
|
+
denominator <= 0n ||
|
|
152
|
+
denominator > u64max)
|
|
153
|
+
throw new RangeError("Invalid rational components");
|
|
154
|
+
let a = numerator < 0n ? -numerator : numerator;
|
|
155
|
+
let b = denominator;
|
|
156
|
+
while (b !== 0n) {
|
|
157
|
+
const remainder = a % b;
|
|
158
|
+
a = b;
|
|
159
|
+
b = remainder;
|
|
160
|
+
}
|
|
161
|
+
if (a !== 1n)
|
|
162
|
+
throw new TypeError("Rational is not reduced");
|
|
163
|
+
return Object.freeze({ numerator, denominator });
|
|
164
|
+
}
|
|
165
|
+
export function convertTicksExact(ticks, sourceRate, targetRate) {
|
|
166
|
+
if (typeof ticks !== "bigint" || ticks < i64min || ticks > i64max)
|
|
167
|
+
throw new RangeError("Invalid signed ticks");
|
|
168
|
+
const source = rationalValue(sourceRate.numerator, sourceRate.denominator);
|
|
169
|
+
const target = rationalValue(targetRate.numerator, targetRate.denominator);
|
|
170
|
+
if (source.numerator <= 0n || target.numerator <= 0n)
|
|
171
|
+
throw new RangeError("Timebase must be positive");
|
|
172
|
+
const numerator = ticks * target.numerator * source.denominator;
|
|
173
|
+
const denominator = source.numerator * target.denominator;
|
|
174
|
+
const result = numerator / denominator;
|
|
175
|
+
if (numerator % denominator !== 0n || result < i64min || result > i64max)
|
|
176
|
+
throw new RangeError("Time is not representable");
|
|
177
|
+
return result;
|
|
178
|
+
}
|
package/dist/wire.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DescMessage, MessageShape } from "@bufbuild/protobuf";
|
|
2
|
+
/** The registry's fixed decode and encode bounds. */
|
|
3
|
+
export declare const wireLimits: Readonly<{
|
|
4
|
+
readonly unaryMessage: number;
|
|
5
|
+
readonly helperMessage: number;
|
|
6
|
+
readonly inlinePage: number;
|
|
7
|
+
readonly streamFrame: number;
|
|
8
|
+
readonly largeProjection: number;
|
|
9
|
+
/** Message levels permitted below the root message. */
|
|
10
|
+
readonly nestedMessageLevels: 100;
|
|
11
|
+
}>;
|
|
12
|
+
/** Selected transport size classes from the wire registry. */
|
|
13
|
+
export type WireLimit = Exclude<keyof typeof wireLimits, "nestedMessageLevels">;
|
|
14
|
+
/** Why a bounded contract encode or decode was refused. */
|
|
15
|
+
export type ContractSerializationFailure = "tooLarge" | "tooDeep" | "malformed" | "invalid";
|
|
16
|
+
/** A typed refusal from a bounded contract codec; the message never carries payload content. */
|
|
17
|
+
export declare class ContractSerializationError extends Error {
|
|
18
|
+
readonly failure: ContractSerializationFailure;
|
|
19
|
+
constructor(failure: ContractSerializationFailure, options?: {
|
|
20
|
+
cause?: unknown;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* protobuf-es read options matching the C# decoder: unknown fields are retained
|
|
25
|
+
* and the root plus 100 nested message levels are admitted (protobuf-es counts the root).
|
|
26
|
+
*/
|
|
27
|
+
export declare const contractBinaryReadOptions: Readonly<{
|
|
28
|
+
readUnknownFields: true;
|
|
29
|
+
recursionLimit: number;
|
|
30
|
+
}>;
|
|
31
|
+
/** Decodes one complete message or throws a typed refusal. */
|
|
32
|
+
export declare function decodeContract<Desc extends DescMessage>(schema: Desc, bytes: Uint8Array, limit: WireLimit): MessageShape<Desc>;
|
|
33
|
+
/** Encodes a message only when its serialized size fits the selected class. */
|
|
34
|
+
export declare function encodeContract<Desc extends DescMessage>(schema: Desc, message: MessageShape<Desc>, limit: WireLimit): Uint8Array;
|
package/dist/wire.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { fromBinary, toBinary } from "@bufbuild/protobuf";
|
|
3
|
+
/** The registry's fixed decode and encode bounds. */
|
|
4
|
+
export const wireLimits = Object.freeze({
|
|
5
|
+
unaryMessage: 4 * 1024 * 1024,
|
|
6
|
+
helperMessage: 4 * 1024 * 1024,
|
|
7
|
+
inlinePage: 256 * 1024,
|
|
8
|
+
streamFrame: 32 * 1024,
|
|
9
|
+
largeProjection: 64 * 1024 * 1024,
|
|
10
|
+
/** Message levels permitted below the root message. */
|
|
11
|
+
nestedMessageLevels: 100,
|
|
12
|
+
});
|
|
13
|
+
/** A typed refusal from a bounded contract codec; the message never carries payload content. */
|
|
14
|
+
export class ContractSerializationError extends Error {
|
|
15
|
+
failure;
|
|
16
|
+
constructor(failure, options) {
|
|
17
|
+
super(`Contract serialization refused: ${failure}.`, options);
|
|
18
|
+
this.name = "ContractSerializationError";
|
|
19
|
+
this.failure = failure;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* protobuf-es read options matching the C# decoder: unknown fields are retained
|
|
24
|
+
* and the root plus 100 nested message levels are admitted (protobuf-es counts the root).
|
|
25
|
+
*/
|
|
26
|
+
export const contractBinaryReadOptions = Object.freeze({
|
|
27
|
+
readUnknownFields: true,
|
|
28
|
+
recursionLimit: wireLimits.nestedMessageLevels + 1,
|
|
29
|
+
});
|
|
30
|
+
/** Decodes one complete message or throws a typed refusal. */
|
|
31
|
+
export function decodeContract(schema, bytes, limit) {
|
|
32
|
+
if (bytes.byteLength > wireLimits[limit])
|
|
33
|
+
throw new ContractSerializationError("tooLarge");
|
|
34
|
+
try {
|
|
35
|
+
return fromBinary(schema, bytes, contractBinaryReadOptions);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
// protobuf-es reports recursion exhaustion through its fixed depth message.
|
|
39
|
+
const deep = error instanceof Error && error.message.includes("maximum recursion depth");
|
|
40
|
+
throw new ContractSerializationError(deep ? "tooDeep" : "malformed", { cause: error });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Encodes a message only when its serialized size fits the selected class. */
|
|
44
|
+
export function encodeContract(schema, message, limit) {
|
|
45
|
+
const bytes = toBinary(schema, message, { writeUnknownFields: true });
|
|
46
|
+
if (bytes.byteLength > wireLimits[limit])
|
|
47
|
+
throw new ContractSerializationError("tooLarge");
|
|
48
|
+
return bytes;
|
|
49
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@arcforges/proto",
|
|
3
|
+
"version": "1.0.0-ci.101.1",
|
|
4
|
+
"description": "ArcForges public foundation and domain protobuf messages, shape validation and exact value adapters.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/ArcForges/Contracts.git",
|
|
11
|
+
"directory": "src/public/ts/proto"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/ArcForges/Contracts#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/ArcForges/Contracts/issues"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./build-identity": "./build-identity.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"LICENSE",
|
|
26
|
+
"NOTICE",
|
|
27
|
+
"README.md",
|
|
28
|
+
"build-identity.json",
|
|
29
|
+
"contracts.binpb",
|
|
30
|
+
"dist",
|
|
31
|
+
"proto",
|
|
32
|
+
"sbom.cdx.json",
|
|
33
|
+
"schemas",
|
|
34
|
+
"source.json"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@bufbuild/protobuf": "2.15.0"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public",
|
|
41
|
+
"registry": "https://registry.npmjs.org/"
|
|
42
|
+
},
|
|
43
|
+
"arcforges": {
|
|
44
|
+
"licenceBoundary": "Apache",
|
|
45
|
+
"contractAccess": "public"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/sbom.cdx.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bomFormat": "CycloneDX",
|
|
3
|
+
"specVersion": "1.6",
|
|
4
|
+
"version": 1,
|
|
5
|
+
"metadata": {
|
|
6
|
+
"component": {
|
|
7
|
+
"type": "library",
|
|
8
|
+
"bom-ref": "pkg:npm/%40arcforges/proto@1.0.0-ci.101.1",
|
|
9
|
+
"name": "@arcforges/proto",
|
|
10
|
+
"version": "1.0.0-ci.101.1",
|
|
11
|
+
"purl": "pkg:npm/%40arcforges/proto@1.0.0-ci.101.1",
|
|
12
|
+
"licenses": [
|
|
13
|
+
{
|
|
14
|
+
"expression": "Apache-2.0"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"components": [
|
|
20
|
+
{
|
|
21
|
+
"type": "library",
|
|
22
|
+
"bom-ref": "pkg:npm/%40bufbuild/protobuf@2.15.0",
|
|
23
|
+
"name": "@bufbuild/protobuf",
|
|
24
|
+
"version": "2.15.0",
|
|
25
|
+
"purl": "pkg:npm/%40bufbuild/protobuf@2.15.0",
|
|
26
|
+
"licenses": [
|
|
27
|
+
{
|
|
28
|
+
"expression": "(Apache-2.0 AND BSD-3-Clause)"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"dependencies": [
|
|
34
|
+
{
|
|
35
|
+
"ref": "pkg:npm/%40bufbuild/protobuf@2.15.0",
|
|
36
|
+
"dependsOn": []
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"ref": "pkg:npm/%40arcforges/proto@1.0.0-ci.101.1",
|
|
40
|
+
"dependsOn": [
|
|
41
|
+
"pkg:npm/%40bufbuild/protobuf@2.15.0"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
syntax = "proto3";
|
|
3
|
+
|
|
4
|
+
package arcforges.events.v1;
|
|
5
|
+
|
|
6
|
+
option csharp_namespace = "ArcForges.Contracts.Events.V1";
|
|
7
|
+
option java_package = "io.github.arcforges.contracts.events.v1";
|
|
8
|
+
option java_multiple_files = true;
|
|
9
|
+
option java_outer_classname = "EventsProto";
|
|
10
|
+
|
|
11
|
+
// The complete entitlement.changed hint payload; not the full Event envelope.
|
|
12
|
+
message EntitlementChanged {
|
|
13
|
+
optional int64 entitlement_version = 1 [json_name = "entitlementVersion"];
|
|
14
|
+
}
|