@xyo-network/xl1-protocol-sdk 4.0.2 → 4.0.4
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/neutral/CreatableProvider/AbstractCreatableProvider.d.ts +1 -0
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts.map +1 -1
- package/dist/neutral/capabilities/locatorFromConfig.d.ts +3 -3
- package/dist/neutral/capabilities/locatorFromConfig.d.ts.map +1 -1
- package/dist/neutral/config/Actor.d.ts +7 -1
- package/dist/neutral/config/Actor.d.ts.map +1 -1
- package/dist/neutral/config/Actors.d.ts +1 -0
- package/dist/neutral/config/Actors.d.ts.map +1 -1
- package/dist/neutral/config/Base.d.ts +39 -34
- package/dist/neutral/config/Base.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +5 -1
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/HostActor.d.ts +7 -1
- package/dist/neutral/config/HostActor.d.ts.map +1 -1
- package/dist/neutral/config/LocatorConfigFields.d.ts +115 -0
- package/dist/neutral/config/LocatorConfigFields.d.ts.map +1 -0
- package/dist/neutral/config/ProviderBinding.d.ts +2 -0
- package/dist/neutral/config/ProviderBinding.d.ts.map +1 -1
- package/dist/neutral/config/ResolvedLocatorConfig.d.ts +122 -0
- package/dist/neutral/config/ResolvedLocatorConfig.d.ts.map +1 -0
- package/dist/neutral/config/index.d.ts +2 -0
- package/dist/neutral/config/index.d.ts.map +1 -1
- package/dist/neutral/config/resolveRestConnectionEndpoint.d.ts +2 -2
- package/dist/neutral/config/resolveRestConnectionEndpoint.d.ts.map +1 -1
- package/dist/neutral/context/Actor.d.ts +7 -1
- package/dist/neutral/context/Actor.d.ts.map +1 -1
- package/dist/neutral/context/HostActor.d.ts +7 -1
- package/dist/neutral/context/HostActor.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.d.ts +2 -0
- package/dist/neutral/getFileConfig.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.mjs +11 -5
- package/dist/neutral/getFileConfig.mjs.map +3 -3
- package/dist/neutral/index.mjs +75 -6
- package/dist/neutral/index.mjs.map +3 -3
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts +13 -7
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts.map +1 -1
- package/dist/neutral/test/index.mjs +11 -5
- package/dist/neutral/test/index.mjs.map +3 -3
- package/package.json +7 -7
package/dist/neutral/index.mjs
CHANGED
|
@@ -1703,7 +1703,7 @@ import {
|
|
|
1703
1703
|
} from "@xylabs/sdk";
|
|
1704
1704
|
import { globalRegistry as globalRegistry9, z as z14 } from "zod/mini";
|
|
1705
1705
|
|
|
1706
|
-
// src/config/
|
|
1706
|
+
// src/config/LocatorConfigFields.ts
|
|
1707
1707
|
import { z as z13 } from "zod/mini";
|
|
1708
1708
|
|
|
1709
1709
|
// src/config/Chain.ts
|
|
@@ -1919,6 +1919,11 @@ var ProviderBindingConfigZod = z8.object({
|
|
|
1919
1919
|
description: "Named connection from the top-level connections map",
|
|
1920
1920
|
title: "providerBindings.connection",
|
|
1921
1921
|
type: "string"
|
|
1922
|
+
}),
|
|
1923
|
+
provider: z8.string().optional().register(globalRegistry6, {
|
|
1924
|
+
description: "Winning provider descriptor id when config is compile-resolved",
|
|
1925
|
+
title: "providerBindings.provider",
|
|
1926
|
+
type: "string"
|
|
1922
1927
|
})
|
|
1923
1928
|
}).describe("Provider connection binding");
|
|
1924
1929
|
var ProviderBindingsConfigZod = z8.record(z8.string(), ProviderBindingConfigZod).default({});
|
|
@@ -2922,8 +2927,8 @@ var ValidationConfigZod = z12.object({
|
|
|
2922
2927
|
})
|
|
2923
2928
|
});
|
|
2924
2929
|
|
|
2925
|
-
// src/config/
|
|
2926
|
-
var
|
|
2930
|
+
// src/config/LocatorConfigFields.ts
|
|
2931
|
+
var LocatorConfigFieldsZod = z13.strictObject({
|
|
2927
2932
|
chain: z13._default(ChainConfigZod, ChainConfigZod.parse({})).check(z13.describe("Configuration for the chain")),
|
|
2928
2933
|
log: z13._default(LogConfigZod, LogConfigZod.parse({})).check(z13.describe("Configuration for logging")),
|
|
2929
2934
|
connections: z13._default(ConnectionsConfigZod, ConnectionsConfigZod.parse({})).check(z13.describe("Named connection profiles (rpc, rest, s3, lmdb, mongo, evm-rpc)")),
|
|
@@ -2932,13 +2937,25 @@ var BaseConfigZod = z13.object({
|
|
|
2932
2937
|
telemetry: z13._default(TelemetryConfigZod, TelemetryConfigZod.parse({})).check(z13.describe("Configuration for telemetry")),
|
|
2933
2938
|
validation: z13._default(ValidationConfigZod, ValidationConfigZod.parse({})).check(z13.describe("Configuration for validation"))
|
|
2934
2939
|
});
|
|
2940
|
+
var LOCATOR_CONFIG_FIELD_KEYS = Object.keys(LocatorConfigFieldsZod.shape);
|
|
2941
|
+
function isRecord(value) {
|
|
2942
|
+
return typeof value === "object" && value !== null;
|
|
2943
|
+
}
|
|
2944
|
+
function parseLocatorConfigFields(raw) {
|
|
2945
|
+
const source = isRecord(raw) ? raw : {};
|
|
2946
|
+
const section = {};
|
|
2947
|
+
for (const key of LOCATOR_CONFIG_FIELD_KEYS) {
|
|
2948
|
+
if (Object.hasOwn(source, key)) section[key] = source[key];
|
|
2949
|
+
}
|
|
2950
|
+
return LocatorConfigFieldsZod.parse(section);
|
|
2951
|
+
}
|
|
2935
2952
|
|
|
2936
2953
|
// src/config/Actor.ts
|
|
2937
2954
|
var AccountPathZod = z14.string().check(z14.regex(
|
|
2938
2955
|
/^(m(\/\d+'?)+|\d+'?(\/\d+'?)*)$/,
|
|
2939
2956
|
`Invalid BIP-32 derivation path. Use either an absolute path like "m/44'/60'/0'/0/0" or a relative path like "0", "0/1", or "44'/60'/0'/0/0".`
|
|
2940
2957
|
));
|
|
2941
|
-
var ActorConfigZod = z14.extend(
|
|
2958
|
+
var ActorConfigZod = z14.extend(LocatorConfigFieldsZod, {
|
|
2942
2959
|
name: z14.string(),
|
|
2943
2960
|
accountPath: z14.optional(AccountPathZod).register(globalRegistry9, {
|
|
2944
2961
|
description: 'BIP-32 derivation path for the actor wallet. Absolute when it starts with "m/"; otherwise relative to the root wallet base path. Each actor must derive to a distinct path.',
|
|
@@ -2957,9 +2974,12 @@ var ActorsConfigZod = z15._default(
|
|
|
2957
2974
|
[]
|
|
2958
2975
|
);
|
|
2959
2976
|
|
|
2977
|
+
// src/config/Base.ts
|
|
2978
|
+
var BaseConfigZod = LocatorConfigFieldsZod;
|
|
2979
|
+
|
|
2960
2980
|
// src/config/Config.ts
|
|
2961
2981
|
import { globalRegistry as globalRegistry10, z as z16 } from "zod/mini";
|
|
2962
|
-
var ConfigZod = z16.extend(
|
|
2982
|
+
var ConfigZod = z16.extend(LocatorConfigFieldsZod, {
|
|
2963
2983
|
actors: ActorsConfigZod,
|
|
2964
2984
|
healthCheckPort: z16.optional(z16.coerce.number()).register(globalRegistry10, {
|
|
2965
2985
|
description: "Port for the system-wide health, readiness, and liveness endpoints (/healthz, /livez, /readyz). Set to 0 to disable.",
|
|
@@ -3005,6 +3025,51 @@ var isHostActorConfig = zodIsFactory3(HostActorConfigZod);
|
|
|
3005
3025
|
var asHostActorConfig = zodAsFactory4(HostActorConfigZod, "asHostActorConfig");
|
|
3006
3026
|
var toHostActorConfig = zodToFactory3(HostActorConfigZod, "toHostActorConfig");
|
|
3007
3027
|
|
|
3028
|
+
// src/config/ResolvedLocatorConfig.ts
|
|
3029
|
+
function assertConnectionReferences(config) {
|
|
3030
|
+
const connections = config.connections ?? {};
|
|
3031
|
+
for (const [moniker, binding] of Object.entries(config.providerBindings ?? {})) {
|
|
3032
|
+
const connectionName = binding?.connection;
|
|
3033
|
+
if (connectionName === void 0 || connectionName === "") continue;
|
|
3034
|
+
if (!Object.hasOwn(connections, connectionName)) {
|
|
3035
|
+
throw new Error(
|
|
3036
|
+
`Resolved locator config: providerBindings.${moniker}.connection references unknown connection "${connectionName}"`
|
|
3037
|
+
);
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
3041
|
+
function assertRequiredBindings(config, needs) {
|
|
3042
|
+
for (const moniker of needs.required) {
|
|
3043
|
+
const binding = config.providerBindings?.[moniker];
|
|
3044
|
+
if (binding === void 0) {
|
|
3045
|
+
throw new Error(
|
|
3046
|
+
`Resolved locator config: missing providerBindings entry for required moniker "${moniker}"`
|
|
3047
|
+
);
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
function assertResolvedLocatorConfig(raw, options = {}) {
|
|
3052
|
+
const config = LocatorConfigFieldsZod.parse(raw);
|
|
3053
|
+
assertConnectionReferences(config);
|
|
3054
|
+
if (options.needs !== void 0) {
|
|
3055
|
+
assertRequiredBindings(config, options.needs);
|
|
3056
|
+
}
|
|
3057
|
+
return config;
|
|
3058
|
+
}
|
|
3059
|
+
var ResolvedLocatorConfigZod = LocatorConfigFieldsZod.check((ctx) => {
|
|
3060
|
+
try {
|
|
3061
|
+
assertConnectionReferences(ctx.value);
|
|
3062
|
+
} catch (error) {
|
|
3063
|
+
if (error instanceof Error) {
|
|
3064
|
+
ctx.issues.push({
|
|
3065
|
+
code: "custom",
|
|
3066
|
+
message: error.message,
|
|
3067
|
+
input: ctx.value
|
|
3068
|
+
});
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
});
|
|
3072
|
+
|
|
3008
3073
|
// src/config/resolveRestConnectionEndpoint.ts
|
|
3009
3074
|
import { assertEx as assertEx21, isDefined as isDefined14 } from "@xylabs/sdk";
|
|
3010
3075
|
function asRestConnectionConfig(connection) {
|
|
@@ -3111,7 +3176,7 @@ import { z as z19 } from "zod/mini";
|
|
|
3111
3176
|
var SystemStatusRunnerZod = z19.custom((val) => val !== null && val !== void 0 && typeof val === "object");
|
|
3112
3177
|
var ProviderFactoryLocatorZod = z19.lazy(() => z19.custom((val) => val !== null && val !== void 0 && typeof val === "object" && "context" in val && "registry" in val));
|
|
3113
3178
|
var BaseConfigContextZod = z19.extend(CachingContextZod, {
|
|
3114
|
-
config: z19.looseObject(
|
|
3179
|
+
config: z19.looseObject(LocatorConfigFieldsZod.shape),
|
|
3115
3180
|
locator: z19.optional(ProviderFactoryLocatorZod)
|
|
3116
3181
|
});
|
|
3117
3182
|
var CreatableProviderContextZod = z19.lazy(() => z19.extend(BaseConfigContextZod, {
|
|
@@ -7962,6 +8027,7 @@ export {
|
|
|
7962
8027
|
HydratedCache,
|
|
7963
8028
|
JSONSchemaMetaSchema,
|
|
7964
8029
|
LmdbConnectionConfigZod,
|
|
8030
|
+
LocatorConfigFieldsZod,
|
|
7965
8031
|
LoggerStatusReporter,
|
|
7966
8032
|
MemoryArchivistFactory,
|
|
7967
8033
|
MemoryConnectionConfigZod,
|
|
@@ -7984,6 +8050,7 @@ export {
|
|
|
7984
8050
|
ProvidersConfigZod,
|
|
7985
8051
|
REJECTED_BLOCKS_ARCHIVIST_ROLE,
|
|
7986
8052
|
REJECTED_TRANSACTIONS_ARCHIVIST_ROLE,
|
|
8053
|
+
ResolvedLocatorConfigZod,
|
|
7987
8054
|
RestConnectionConfigZod,
|
|
7988
8055
|
RestDataLakeRunner,
|
|
7989
8056
|
RestDataLakeViewer,
|
|
@@ -8072,6 +8139,7 @@ export {
|
|
|
8072
8139
|
asSchemasStepSummaryWithStorageMeta,
|
|
8073
8140
|
asTransfersStepSummary,
|
|
8074
8141
|
asTransfersStepSummaryWithStorageMeta,
|
|
8142
|
+
assertResolvedLocatorConfig,
|
|
8075
8143
|
backedFactory,
|
|
8076
8144
|
backingsSatisfied,
|
|
8077
8145
|
balancesMaxStep,
|
|
@@ -8183,6 +8251,7 @@ export {
|
|
|
8183
8251
|
networkBackedFactory,
|
|
8184
8252
|
networkStakeStepRewardPositionWeight,
|
|
8185
8253
|
normalizeConnectionsConfig,
|
|
8254
|
+
parseLocatorConfigFields,
|
|
8186
8255
|
parseSignedBigInt,
|
|
8187
8256
|
payloadMapFromStore,
|
|
8188
8257
|
prettifyZodError,
|