@secondlayer/shared 7.0.2 → 7.0.3
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/src/crypto/secondlayer-webhook.js +2 -2
- package/dist/src/crypto/secondlayer-webhook.js.map +2 -2
- package/dist/src/db/index.js +2 -2
- package/dist/src/db/index.js.map +2 -2
- package/dist/src/db/queries/chain-reorgs.js +2 -2
- package/dist/src/db/queries/chain-reorgs.js.map +2 -2
- package/dist/src/db/queries/subgraphs.js +2 -2
- package/dist/src/db/queries/subgraphs.js.map +2 -2
- package/dist/src/env.d.ts +1 -1
- package/dist/src/env.js +2 -2
- package/dist/src/env.js.map +2 -2
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.js +5 -5
- package/dist/src/index.js.map +5 -5
- package/dist/src/leader.js +2 -2
- package/dist/src/leader.js.map +2 -2
- package/dist/src/logger.js +2 -2
- package/dist/src/logger.js.map +2 -2
- package/dist/src/node/archive-client.js +2 -2
- package/dist/src/node/archive-client.js.map +2 -2
- package/dist/src/node/hiro-client.js +2 -2
- package/dist/src/node/hiro-client.js.map +2 -2
- package/dist/src/schemas/filters.d.ts +1 -1
- package/dist/src/schemas/filters.js +2 -2
- package/dist/src/schemas/filters.js.map +2 -2
- package/dist/src/schemas/index.d.ts +3 -3
- package/dist/src/schemas/index.js +4 -4
- package/dist/src/schemas/index.js.map +4 -4
- package/dist/src/schemas/subgraphs.d.ts +1 -1
- package/dist/src/schemas/subgraphs.js +2 -2
- package/dist/src/schemas/subgraphs.js.map +2 -2
- package/dist/src/schemas/subscriptions.d.ts +1 -1
- package/dist/src/schemas/subscriptions.js +2 -2
- package/dist/src/schemas/subscriptions.js.map +2 -2
- package/package.json +6 -3
package/dist/src/env.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/env.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { z } from \"zod
|
|
5
|
+
"import { z } from \"zod\";\n\n// Parse comma-separated networks\nconst networksSchema = z.string().transform((val) => {\n\tconst networks = val\n\t\t.split(\",\")\n\t\t.map((n) => n.trim())\n\t\t.filter(Boolean);\n\tconst valid = [\"mainnet\", \"testnet\"];\n\tfor (const n of networks) {\n\t\tif (!valid.includes(n)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid network: ${n}. Must be one of: ${valid.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn networks as (\"mainnet\" | \"testnet\")[];\n});\n\ninterface EnvSchemaOutput {\n\tDATABASE_URL?: string;\n\t/**\n\t * Shared indexer DB (blocks/txs/events). Falls back to DATABASE_URL.\n\t * Set this alongside TARGET_DATABASE_URL to enable dual-DB mode.\n\t */\n\tSOURCE_DATABASE_URL?: string;\n\t/**\n\t * Tenant DB (subgraph schemas + subgraphs table). Falls back to DATABASE_URL.\n\t * Set this alongside SOURCE_DATABASE_URL to enable dual-DB mode.\n\t */\n\tTARGET_DATABASE_URL?: string;\n\tNETWORK?: \"mainnet\" | \"testnet\";\n\tNETWORKS?: (\"mainnet\" | \"testnet\")[];\n\tLOG_LEVEL: \"debug\" | \"info\" | \"warn\" | \"error\";\n\tNODE_ENV: \"development\" | \"production\" | \"test\";\n}\n\n// Cast needed: z.preprocess / z.default create different _input vs _output types\n// that z.ZodType<T> can't represent without explicit input type param\nconst envSchema: z.ZodType<EnvSchemaOutput> = z.object({\n\tDATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tSOURCE_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tTARGET_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tNETWORK: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tNETWORKS: networksSchema.optional(),\n\tLOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\"]).default(\"info\"),\n\tNODE_ENV: z\n\t\t.enum([\"development\", \"production\", \"test\"])\n\t\t.default(\"development\"),\n}) as unknown as z.ZodType<EnvSchemaOutput>;\n\nexport type Env = EnvSchemaOutput & {\n\tenabledNetworks: (\"mainnet\" | \"testnet\")[];\n};\n\nlet cachedEnv: Env | null = null;\n\nexport function getEnv(): Env {\n\tif (cachedEnv) {\n\t\treturn cachedEnv;\n\t}\n\n\tconst result = envSchema.safeParse(process.env);\n\n\tif (!result.success) {\n\t\tconsole.error(\"❌ Invalid environment configuration:\");\n\t\tconsole.error(z.treeifyError(result.error));\n\t\tthrow new Error(\"Invalid environment configuration\");\n\t}\n\n\t// Compute enabled networks from NETWORKS or NETWORK\n\tlet enabledNetworks: (\"mainnet\" | \"testnet\")[];\n\tif (result.data.NETWORKS && result.data.NETWORKS.length > 0) {\n\t\tenabledNetworks = result.data.NETWORKS;\n\t} else if (result.data.NETWORK) {\n\t\tenabledNetworks = [result.data.NETWORK];\n\t} else {\n\t\tenabledNetworks = [\"mainnet\"]; // Default\n\t}\n\n\tcachedEnv = { ...result.data, enabledNetworks };\n\treturn cachedEnv;\n}\n\n/**\n * True when `NODE_ENV=production`, read at RUNTIME — the single source of truth\n * for prod-vs-dev branching in this package.\n *\n * Why a helper instead of inlining `process.env.NODE_ENV === \"production\"`:\n * bunup/esbuild constant-folds the dot-access `process.env.NODE_ENV` to its\n * BUILD-time value. `@secondlayer/shared` is consumed by other services as its\n * built `dist`, so an inlined check freezes to a literal in the shipped bundle\n * (e.g. `const isProd = false`) and silently ignores the container's real\n * NODE_ENV. The bracket access below is NOT folded, so it stays a runtime read.\n * Route every prod check through here so the footgun lives in exactly one place.\n */\nexport function isProductionEnv(): boolean {\n\t// biome-ignore lint/complexity/useLiteralKeys: bracket access is deliberate — dot-access gets constant-folded by the bundler, freezing this to a build-time literal in the shipped dist.\n\treturn process.env[\"NODE_ENV\"] === \"production\";\n}\n\n/**\n * PoX-4 stacking decoder is ON by default — `/v1/index/stacking` is part of the\n * public surface, so the decoder that fills `pox4_calls` runs unless explicitly\n * opted out with `POX4_DECODER_ENABLED=false` (mirrors the sBTC decoder policy).\n */\nexport function isPox4DecoderEnabled(): boolean {\n\treturn process.env.POX4_DECODER_ENABLED !== \"false\";\n}\n\n// Export for testing\nexport { envSchema };\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAGA,IAAM,iBAAiB,EAAE,OAAO,EAAE,UAAU,CAAC,QAAQ;AAAA,EACpD,MAAM,WAAW,IACf,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AAAA,EAChB,MAAM,QAAQ,CAAC,WAAW,SAAS;AAAA,EACnC,WAAW,KAAK,UAAU;AAAA,IACzB,IAAI,CAAC,MAAM,SAAS,CAAC,GAAG;AAAA,MACvB,MAAM,IAAI,MACT,oBAAoB,sBAAsB,MAAM,KAAK,IAAI,GAC1D;AAAA,IACD;AAAA,EACD;AAAA,EACA,OAAO;AAAA,CACP;AAsBD,IAAM,YAAwC,EAAE,OAAO;AAAA,EACtD,cAAc,EAAE,WACf,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B;AAAA,EACA,qBAAqB,EAAE,WACtB,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B;AAAA,EACA,qBAAqB,EAAE,WACtB,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B;AAAA,EACA,SAAS,EAAE,KAAK,CAAC,WAAW,SAAS,CAAC,EAAE,SAAS;AAAA,EACjD,UAAU,eAAe,SAAS;AAAA,EAClC,WAAW,EAAE,KAAK,CAAC,SAAS,QAAQ,QAAQ,OAAO,CAAC,EAAE,QAAQ,MAAM;AAAA,EACpE,UAAU,EACR,KAAK,CAAC,eAAe,cAAc,MAAM,CAAC,EAC1C,QAAQ,aAAa;AACxB,CAAC;AAMD,IAAI,YAAwB;AAErB,SAAS,MAAM,GAAQ;AAAA,EAC7B,IAAI,WAAW;AAAA,IACd,OAAO;AAAA,EACR;AAAA,EAEA,MAAM,SAAS,UAAU,UAAU,QAAQ,GAAG;AAAA,EAE9C,IAAI,CAAC,OAAO,SAAS;AAAA,IACpB,QAAQ,MAAM,sCAAqC;AAAA,IACnD,QAAQ,MAAM,EAAE,aAAa,OAAO,KAAK,CAAC;AAAA,IAC1C,MAAM,IAAI,MAAM,mCAAmC;AAAA,EACpD;AAAA,EAGA,IAAI;AAAA,EACJ,IAAI,OAAO,KAAK,YAAY,OAAO,KAAK,SAAS,SAAS,GAAG;AAAA,IAC5D,kBAAkB,OAAO,KAAK;AAAA,EAC/B,EAAO,SAAI,OAAO,KAAK,SAAS;AAAA,IAC/B,kBAAkB,CAAC,OAAO,KAAK,OAAO;AAAA,EACvC,EAAO;AAAA,IACN,kBAAkB,CAAC,SAAS;AAAA;AAAA,EAG7B,YAAY,KAAK,OAAO,MAAM,gBAAgB;AAAA,EAC9C,OAAO;AAAA;AAeD,SAAS,eAAe,GAAY;AAAA,EAE1C,OAAO,QAAQ,IAAI,gBAAgB;AAAA;AAQ7B,SAAS,oBAAoB,GAAY;AAAA,EAC/C,OAAO,QAAQ,IAAI,yBAAyB;AAAA;",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "189DA17D677C50EE64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2079,7 +2079,7 @@ declare class Logger {
|
|
|
2079
2079
|
error(message: string, meta?: Record<string, any>): void;
|
|
2080
2080
|
}
|
|
2081
2081
|
declare const logger: Logger;
|
|
2082
|
-
import { z as z2 } from "zod
|
|
2082
|
+
import { z as z2 } from "zod";
|
|
2083
2083
|
interface StxTransferFilter {
|
|
2084
2084
|
type: "stx_transfer";
|
|
2085
2085
|
sender?: string;
|
|
@@ -2172,7 +2172,7 @@ declare const ContractCallFilterSchema: z2.ZodType<ContractCallFilter>;
|
|
|
2172
2172
|
declare const ContractDeployFilterSchema: z2.ZodType<ContractDeployFilter>;
|
|
2173
2173
|
declare const PrintEventFilterSchema: z2.ZodType<PrintEventFilter>;
|
|
2174
2174
|
declare const EventFilterSchema: z2.ZodType<EventFilter>;
|
|
2175
|
-
import { z as z3 } from "zod
|
|
2175
|
+
import { z as z3 } from "zod";
|
|
2176
2176
|
interface DeploySubgraphRequest {
|
|
2177
2177
|
name: string;
|
|
2178
2178
|
version?: string;
|
|
@@ -2399,7 +2399,7 @@ interface SubgraphAggregateResponse {
|
|
|
2399
2399
|
min?: Record<string, string | null>;
|
|
2400
2400
|
max?: Record<string, string | null>;
|
|
2401
2401
|
}
|
|
2402
|
-
import { z as z4 } from "zod
|
|
2402
|
+
import { z as z4 } from "zod";
|
|
2403
2403
|
declare const SUBSCRIPTION_FORMATS: readonly ["standard-webhooks", "inngest", "trigger", "cloudflare", "cloudevents", "raw"];
|
|
2404
2404
|
declare const SUBSCRIPTION_RUNTIMES: readonly ["inngest", "trigger", "cloudflare", "node"];
|
|
2405
2405
|
declare const SUBSCRIPTION_STATUSES: readonly ["active", "paused", "error"];
|
package/dist/src/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __export = (target, all) => {
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
// src/env.ts
|
|
17
|
-
import { z } from "zod
|
|
17
|
+
import { z } from "zod";
|
|
18
18
|
var networksSchema = z.string().transform((val) => {
|
|
19
19
|
const networks = val.split(",").map((n) => n.trim()).filter(Boolean);
|
|
20
20
|
const valid = ["mainnet", "testnet"];
|
|
@@ -993,7 +993,7 @@ function getErrorMessage(err) {
|
|
|
993
993
|
|
|
994
994
|
// src/schemas/filters.ts
|
|
995
995
|
import { isValidAddress as _isValidAddress } from "@secondlayer/stacks";
|
|
996
|
-
import { z as z2 } from "zod
|
|
996
|
+
import { z as z2 } from "zod";
|
|
997
997
|
var isValidAddress = _isValidAddress;
|
|
998
998
|
var stacksPrincipal = z2.string().refine((val) => {
|
|
999
999
|
const parts = val.split(".");
|
|
@@ -1096,7 +1096,7 @@ var EventFilterSchema = z2.discriminatedUnion("type", [
|
|
|
1096
1096
|
]);
|
|
1097
1097
|
|
|
1098
1098
|
// src/schemas/subgraphs.ts
|
|
1099
|
-
import { z as z3 } from "zod
|
|
1099
|
+
import { z as z3 } from "zod";
|
|
1100
1100
|
var DeploySubgraphRequestSchema = z3.object({
|
|
1101
1101
|
name: z3.string().regex(/^[a-z0-9-]+$/, "lowercase alphanumeric + hyphens only").max(63),
|
|
1102
1102
|
version: z3.string().optional(),
|
|
@@ -1112,7 +1112,7 @@ var DeploySubgraphRequestSchema = z3.object({
|
|
|
1112
1112
|
});
|
|
1113
1113
|
|
|
1114
1114
|
// src/schemas/subscriptions.ts
|
|
1115
|
-
import { z as z4 } from "zod
|
|
1115
|
+
import { z as z4 } from "zod";
|
|
1116
1116
|
var SUBSCRIPTION_FORMATS = [
|
|
1117
1117
|
"standard-webhooks",
|
|
1118
1118
|
"inngest",
|
|
@@ -2150,5 +2150,5 @@ export {
|
|
|
2150
2150
|
AuthenticationError
|
|
2151
2151
|
};
|
|
2152
2152
|
|
|
2153
|
-
//# debugId=
|
|
2153
|
+
//# debugId=974D666FD969648E64756E2164756E21
|
|
2154
2154
|
//# sourceMappingURL=index.js.map
|