@xyo-network/xl1-rest-block-publisher 2.1.3 → 2.1.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.
@@ -1,9 +1,9 @@
1
1
  import type { S3Client } from '@aws-sdk/client-s3';
2
- import type { CreatableProviderParams } from '@xyo-network/xl1-protocol-sdk';
2
+ import type { CreatableProviderEventData, CreatableProviderParams } from '@xyo-network/xl1-protocol-sdk';
3
3
  import { AbstractCreatableProvider } from '@xyo-network/xl1-protocol-sdk';
4
4
  import type { RestContentEncoding } from './encoding.ts';
5
- /** Shared parameters for S3 publish runners: where and how published files are written. */
6
- export interface S3PublishRunnerParams extends CreatableProviderParams {
5
+ /** Shared parameters for S3-backed providers: where and how files are stored. */
6
+ export interface S3ProviderParams extends CreatableProviderParams {
7
7
  bucket: string;
8
8
  /** S3-compatible client pointed at the target endpoint (e.g. Cloudflare R2). */
9
9
  client: S3Client;
@@ -17,15 +17,18 @@ export declare const IMMUTABLE_CACHE_CONTROL = "public, max-age=31536000, immuta
17
17
  /** Chain state is rewritten as the chain advances. */
18
18
  export declare const MUTABLE_CACHE_CONTROL = "public, max-age=0, must-revalidate";
19
19
  /**
20
- * Base for publish runners targeting S3-compatible storage. Bodies are pre-compressed at
21
- * write time and stored with the matching Content-Encoding plus application/json, so HTTP
22
- * clients decompress transparently — keys keep their `.json` extension.
20
+ * Base for providers targeting S3-compatible storage. Bodies are pre-compressed at write
21
+ * time and stored with the matching Content-Encoding plus application/json, so HTTP clients
22
+ * decompress transparently — keys keep their `.json` extension. Reads decode the stored
23
+ * Content-Encoding back to JSON.
23
24
  */
24
- export declare abstract class AbstractS3PublishRunner<TParams extends S3PublishRunnerParams = S3PublishRunnerParams> extends AbstractCreatableProvider<TParams> {
25
+ export declare abstract class AbstractS3Provider<TParams extends S3ProviderParams = S3ProviderParams, TEventData extends CreatableProviderEventData = CreatableProviderEventData> extends AbstractCreatableProvider<TParams, TEventData> {
25
26
  get bucket(): string;
26
27
  get client(): S3Client;
27
28
  get contentEncoding(): RestContentEncoding;
28
29
  get prefix(): string;
30
+ /** Reads and decodes a stored JSON file, or undefined when the key does not exist. */
31
+ protected getJson(path: string): Promise<unknown>;
29
32
  protected putJson(path: string, json: string, cacheControl: string): Promise<void>;
30
33
  }
31
- //# sourceMappingURL=AbstractS3PublishRunner.d.ts.map
34
+ //# sourceMappingURL=AbstractS3Provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AbstractS3Provider.d.ts","sourceRoot":"","sources":["../../src/AbstractS3Provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAGlD,OAAO,KAAK,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AACxG,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAA;AAEzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAGxD,iFAAiF;AACjF,MAAM,WAAW,gBAAiB,SAAQ,uBAAuB;IAC/D,MAAM,EAAE,MAAM,CAAA;IACd,gFAAgF;IAChF,MAAM,EAAE,QAAQ,CAAA;IAChB,4EAA4E;IAC5E,eAAe,CAAC,EAAE,mBAAmB,CAAA;IACrC,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,iDAAiD;AACjD,eAAO,MAAM,uBAAuB,wCAAwC,CAAA;AAC5E,sDAAsD;AACtD,eAAO,MAAM,qBAAqB,uCAAuC,CAAA;AAEzE;;;;;GAKG;AACH,8BAAsB,kBAAkB,CACtC,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,EACnD,UAAU,SAAS,0BAA0B,GAAG,0BAA0B,CAC1E,SAAQ,yBAAyB,CAAC,OAAO,EAAE,UAAU,CAAC;IACtD,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,IAAI,QAAQ,CAErB;IAED,IAAI,eAAe,IAAI,mBAAmB,CAEzC;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,sFAAsF;cACtE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;cAYvC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWzF"}
@@ -1,6 +1,6 @@
1
1
  import type { BlockPublishRunner, BlockViewer, SignedHydratedBlockWithHashMeta, XL1BlockNumber, XL1BlockRange } from '@xyo-network/xl1-protocol-lib';
2
- import type { S3PublishRunnerParams } from './AbstractS3PublishRunner.ts';
3
- import { AbstractS3PublishRunner } from './AbstractS3PublishRunner.ts';
2
+ import type { S3ProviderParams } from './AbstractS3Provider.ts';
3
+ import { AbstractS3Provider } from './AbstractS3Provider.ts';
4
4
  /** A progress event emitted while publishing blocks. */
5
5
  export interface BlockPublishProgress {
6
6
  blockNumber: XL1BlockNumber;
@@ -8,7 +8,7 @@ export interface BlockPublishProgress {
8
8
  total: number;
9
9
  }
10
10
  /** Parameters for S3BlockPublishRunner. */
11
- export interface S3BlockPublishRunnerParams extends S3PublishRunnerParams {
11
+ export interface S3BlockPublishRunnerParams extends S3ProviderParams {
12
12
  /** Maximum concurrent block publishes during sync. */
13
13
  concurrency?: number;
14
14
  /**
@@ -18,8 +18,11 @@ export interface S3BlockPublishRunnerParams extends S3PublishRunnerParams {
18
18
  onProgress?: (event: BlockPublishProgress) => void;
19
19
  /** How many block publishes between progress reports during sync. */
20
20
  progressInterval?: number;
21
- /** The viewer to publish from (only finalized chains should be published). */
22
- source: BlockViewer;
21
+ /**
22
+ * The viewer to publish from (only finalized chains should be published). When omitted,
23
+ * resolved from the locator via BlockViewerMoniker.
24
+ */
25
+ source?: BlockViewer;
23
26
  }
24
27
  /**
25
28
  * Publishes finalized blocks (and their payloads) as the static REST file layout that
@@ -29,14 +32,16 @@ export interface S3BlockPublishRunnerParams extends S3PublishRunnerParams {
29
32
  * any range is safe. `sync(from)` resumes from a caller-supplied cursor (typically the block
30
33
  * after the last published head); omitting it republishes from genesis, which is safe.
31
34
  */
32
- export declare class S3BlockPublishRunner extends AbstractS3PublishRunner<S3BlockPublishRunnerParams> implements BlockPublishRunner {
35
+ export declare class S3BlockPublishRunner extends AbstractS3Provider<S3BlockPublishRunnerParams> implements BlockPublishRunner {
33
36
  static readonly defaultMoniker: "BlockPublishRunner";
34
- static readonly dependencies: never[];
37
+ static readonly dependencies: "BlockViewer"[];
35
38
  static readonly monikers: "BlockPublishRunner"[];
36
39
  moniker: "BlockPublishRunner";
40
+ protected _source?: BlockViewer;
37
41
  get concurrency(): number;
38
42
  get progressInterval(): number;
39
43
  get source(): BlockViewer;
44
+ createHandler(): Promise<void>;
40
45
  /** Publishes one block at its by-number and by-hash paths, plus its payload files. */
41
46
  publishBlock(blockNumber: XL1BlockNumber): Promise<SignedHydratedBlockWithHashMeta | null>;
42
47
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"S3BlockPublishRunner.d.ts","sourceRoot":"","sources":["../../src/S3BlockPublishRunner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAAE,WAAW,EAAE,+BAA+B,EAAE,cAAc,EAAE,aAAa,EAChG,MAAM,+BAA+B,CAAA;AAQtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACzE,OAAO,EAAE,uBAAuB,EAA2B,MAAM,8BAA8B,CAAA;AAE/F,wDAAwD;AACxD,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,cAAc,CAAA;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,2CAA2C;AAC3C,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB;IACvE,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,KAA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gBAAgB;IAClE,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAA;IAClD,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED;;;;;;;GAOG;AACH,qBACa,oBAAqB,SAAQ,kBAAkB,CAAC,0BAA0B,CAAE,YAAW,kBAAkB;IACpH,MAAM,CAAC,QAAQ,CAAC,cAAc,uBAA4B;IAC1D,MAAM,CAAC,QAAQ,CAAC,YAAY,kBAAuB;IACnD,MAAM,CAAC,QAAQ,CAAC,QAAQ,yBAA8B;IACtD,OAAO,uBAAsC;IAE7C,SAAS,CAAC,OAAO,CAAC,EAAE,WAAW,CAAA;IAE/B,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAED,IAAI,MAAM,IAAI,WAAW,CAExB;IAEc,aAAa;IAK5B,sFAAsF;IAChF,YAAY,CAAC,WAAW,EAAE,cAAc,GAAG,OAAO,CAAC,+BAA+B,GAAG,IAAI,CAAC;IAYhG;;;OAGG;IACG,IAAI,CAAC,IAAI,GAAE,cAA0C,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAqB3F,6FAA6F;IAC7F,OAAO,CAAC,MAAM;CAQf"}
@@ -1,10 +1,13 @@
1
1
  import type { ChainStatePublishRunner, ChainStateViewerMethods, SignedHydratedBlockWithHashMeta } from '@xyo-network/xl1-protocol-lib';
2
- import type { S3PublishRunnerParams } from './AbstractS3PublishRunner.ts';
3
- import { AbstractS3PublishRunner } from './AbstractS3PublishRunner.ts';
2
+ import type { S3ProviderParams } from './AbstractS3Provider.ts';
3
+ import { AbstractS3Provider } from './AbstractS3Provider.ts';
4
4
  /** Parameters for S3ChainStatePublishRunner. */
5
- export interface S3ChainStatePublishRunnerParams extends S3PublishRunnerParams {
6
- /** Where the current head is read from (any BlockViewer satisfies this). */
7
- source: ChainStateViewerMethods;
5
+ export interface S3ChainStatePublishRunnerParams extends S3ProviderParams {
6
+ /**
7
+ * Where the current head is read from (any BlockViewer satisfies this). When omitted,
8
+ * resolved from the locator via BlockViewerMoniker.
9
+ */
10
+ source?: ChainStateViewerMethods;
8
11
  }
9
12
  /**
10
13
  * Publishes the mutable chain state — the head pointer (`chain/head.json`) — that
@@ -14,12 +17,14 @@ export interface S3ChainStatePublishRunnerParams extends S3PublishRunnerParams {
14
17
  * Callers must publish the finalized files for a head before publishing the head itself,
15
18
  * so readers never see a head that references missing files.
16
19
  */
17
- export declare class S3ChainStatePublishRunner extends AbstractS3PublishRunner<S3ChainStatePublishRunnerParams> implements ChainStatePublishRunner {
20
+ export declare class S3ChainStatePublishRunner extends AbstractS3Provider<S3ChainStatePublishRunnerParams> implements ChainStatePublishRunner {
18
21
  static readonly defaultMoniker: "ChainStatePublishRunner";
19
- static readonly dependencies: never[];
22
+ static readonly dependencies: "BlockViewer"[];
20
23
  static readonly monikers: "ChainStatePublishRunner"[];
21
24
  moniker: "ChainStatePublishRunner";
25
+ protected _source?: ChainStateViewerMethods;
22
26
  get source(): ChainStateViewerMethods;
27
+ createHandler(): Promise<void>;
23
28
  /** Publishes the source's current head to the mutable chain state pointer. */
24
29
  publishHead(): Promise<SignedHydratedBlockWithHashMeta>;
25
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"S3ChainStatePublishRunner.d.ts","sourceRoot":"","sources":["../../src/S3ChainStatePublishRunner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,uBAAuB,EAAE,uBAAuB,EAAE,+BAA+B,EAClF,MAAM,+BAA+B,CAAA;AAKtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACzE,OAAO,EAAE,uBAAuB,EAAyB,MAAM,8BAA8B,CAAA;AAE7F,gDAAgD;AAChD,MAAM,WA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AI,OAAO,CAAC,+BAA+B,CAAC;CAM9D"}
@@ -0,0 +1,26 @@
1
+ import type { Hash } from '@xylabs/sdk-js';
2
+ import type { ChainStateViewer, SignedHydratedBlockWithHashMeta, XL1BlockNumber } from '@xyo-network/xl1-protocol-lib';
3
+ import type { S3ProviderParams } from './AbstractS3Provider.ts';
4
+ import { AbstractS3Provider } from './AbstractS3Provider.ts';
5
+ /** Parameters for S3ChainStateViewer. */
6
+ export interface S3ChainStateViewerParams extends S3ProviderParams {
7
+ }
8
+ /**
9
+ * A ChainStateViewer over the chain-state bucket, reading the published head pointer back
10
+ * through the S3 API (authenticated, not the public HTTP layout — see RestChainStateViewer
11
+ * for anonymous reads). This is how publishers learn their resume cursor: the head pointer
12
+ * is only written after the finalized files it references exist.
13
+ */
14
+ export declare class S3ChainStateViewer extends AbstractS3Provider<S3ChainStateViewerParams, ChainStateViewer['eventData']> implements ChainStateViewer {
15
+ static readonly defaultMoniker: "ChainStateViewer";
16
+ static readonly dependencies: never[];
17
+ static readonly monikers: "ChainStateViewer"[];
18
+ moniker: "ChainStateViewer";
19
+ /** The published head; throws when no head pointer has been published yet. */
20
+ currentBlock(): Promise<SignedHydratedBlockWithHashMeta>;
21
+ currentBlockHash(): Promise<Hash>;
22
+ currentBlockNumber(): Promise<XL1BlockNumber>;
23
+ /** The published head, or undefined when no head pointer has been published yet. */
24
+ tryCurrentBlock(): Promise<SignedHydratedBlockWithHashMeta | undefined>;
25
+ }
26
+ //# sourceMappingURL=S3ChainStateViewer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"S3ChainStateViewer.d.ts","sourceRoot":"","sources":["../../src/S3ChainStateViewer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,KAAK,EACV,gBAAgB,EAAE,+BAA+B,EAAE,cAAc,EAClE,MAAM,+BAA+B,CAAA;AAKtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,yCAAyC;AACzC,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;CAAG;AAErE;;;;;GAKG;AACH,qBACa,kBAAmB,SAAQ,kBAAkB,CAAC,wBAAwB,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAChH,YAAW,gBAAgB;IAC3B,MAAM,CAAC,QAAQ,CAAC,cAAc,qBAA0B;IACxD,MAAM,CAAC,QAAQ,CAAC,YAAY,UAAK;IACjC,MAAM,CAAC,QAAQ,CAAC,QAAQ,uBAA4B;IACpD,OAAO,qBAAoC;IAE3C,8EAA8E;IACxE,YAAY,IAAI,OAAO,CAAC,+BAA+B,CAAC;IAOxD,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC,kBAAkB,IAAI,OAAO,CAAC,cAAc,CAAC;IAInD,oFAAoF;IAC9E,eAAe,IAAI,OAAO,CAAC,+BAA+B,GAAG,SAAS,CAAC;CAI9E"}
@@ -1,22 +1,27 @@
1
1
  import type { BlockViewer, IndexPublishRunner, XL1BlockNumber } from '@xyo-network/xl1-protocol-lib';
2
- import type { S3PublishRunnerParams } from './AbstractS3PublishRunner.ts';
3
- import { AbstractS3PublishRunner } from './AbstractS3PublishRunner.ts';
2
+ import type { S3ProviderParams } from './AbstractS3Provider.ts';
3
+ import { AbstractS3Provider } from './AbstractS3Provider.ts';
4
4
  /** Parameters for S3IndexPublishRunner. */
5
- export interface S3IndexPublishRunnerParams extends S3PublishRunnerParams {
6
- /** The viewer to publish from (only finalized chains should be published). */
7
- source: BlockViewer;
5
+ export interface S3IndexPublishRunnerParams extends S3ProviderParams {
6
+ /**
7
+ * The viewer to publish from (only finalized chains should be published). When omitted,
8
+ * resolved from the locator via BlockViewerMoniker.
9
+ */
10
+ source?: BlockViewer;
8
11
  }
9
12
  /**
10
13
  * Publishes completed steps' block summaries (the chain index) as the static REST file
11
14
  * layout that `RestIndexViewer` reads. Step files are immutable: only complete steps are
12
15
  * ever published, and a completed step's blocks never change.
13
16
  */
14
- export declare class S3IndexPublishRunner extends AbstractS3PublishRunner<S3IndexPublishRunnerParams> implements IndexPublishRunner {
17
+ export declare class S3IndexPublishRunner extends AbstractS3Provider<S3IndexPublishRunnerParams> implements IndexPublishRunner {
15
18
  static readonly defaultMoniker: "IndexPublishRunner";
16
- static readonly dependencies: never[];
19
+ static readonly dependencies: "BlockViewer"[];
17
20
  static readonly monikers: "IndexPublishRunner"[];
18
21
  moniker: "IndexPublishRunner";
22
+ protected _source?: BlockViewer;
19
23
  get source(): BlockViewer;
24
+ createHandler(): Promise<void>;
20
25
  /**
21
26
  * Publishes one completed step's blocks as a BlocksStepSummary file (blocks oldest-first).
22
27
  * Asserts the step is complete — partial tail steps are never published.
@@ -1 +1 @@
1
- {"version":3,"file":"S3IndexPublishRunner.d.ts","sourceRoot":"","sources":["../../src/S3IndexPublishRunner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACS,WAAW,EAAE,kBAAkB,EAAE,cAAc,EACnE,MAAM,+BAA+B,CAAA;AAOtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACzE,OAAO,EAAE,uBAAuB,EAA2B,MAAM,8BAA8B,CAAA;AAE/F,2CAA2C;AAC3C,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB;IACvE,8EAA8E;IAC9E,MAAM,EAAE,WAAW,CAAA;CACpB;AAED;;;;GAIG;AACH,qBACa,oBAAqB,SAAQ,uBAAuB,CAAC,0BAA0B,CAAE,YAAW,kBAAkB;IACzH,MAAM,CAAC,QAAQ,CAAC,cAAc,uBAA4B;IAC1D,MAAM,CAAC,QAAQ,CAAC,YAAY,UAAK;IACjC,MAAM,CAAC,QAAQ,CAAC,QAAQ,yBAA8B;IACtD,OAAO,uBAAsC;IAE7C,IAAI,MAAM,IAAI,WAAW,CAExB;IAED;;;OAGG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBtE,0EAA0E;IACpE,uBAAuB,CAAC,WAAW,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ1E"}
1
+ {"version":3,"file":"S3IndexPublishRunner.d.ts","sourceRoot":"","sources":["../../src/S3IndexPublishRunner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACS,WAAW,EAAE,kBAAkB,EAAE,cAAc,EACnE,MAAM,+BAA+B,CAAA;AAOtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,kBAAkB,EAA2B,MAAM,yBAAyB,CAAA;AAErF,2CAA2C;AAC3C,MAAM,WAAW,0BAA2B,SAAQ,gBAAgB;IAClE;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED;;;;GAIG;AACH,qBACa,oBAAqB,SAAQ,kBAAkB,CAAC,0BAA0B,CAAE,YAAW,kBAAkB;IACpH,MAAM,CAAC,QAAQ,CAAC,cAAc,uBAA4B;IAC1D,MAAM,CAAC,QAAQ,CAAC,YAAY,kBAAuB;IACnD,MAAM,CAAC,QAAQ,CAAC,QAAQ,yBAA8B;IACtD,OAAO,uBAAsC;IAE7C,SAAS,CAAC,OAAO,CAAC,EAAE,WAAW,CAAA;IAE/B,IAAI,MAAM,IAAI,WAAW,CAExB;IAEc,aAAa;IAK5B;;;OAGG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBtE,0EAA0E;IACpE,uBAAuB,CAAC,WAAW,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ1E"}
@@ -1,6 +1,7 @@
1
- export * from './AbstractS3PublishRunner.ts';
1
+ export * from './AbstractS3Provider.ts';
2
2
  export * from './encoding.ts';
3
3
  export * from './S3BlockPublishRunner.ts';
4
4
  export * from './S3ChainStatePublishRunner.ts';
5
+ export * from './S3ChainStateViewer.ts';
5
6
  export * from './S3IndexPublishRunner.ts';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,eAAe,CAAA;AAC7B,cAAc,2BAA2B,CAAA;AACzC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,2BAA2B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,eAAe,CAAA;AAC7B,cAAc,2BAA2B,CAAA;AACzC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,yBAAyB,CAAA;AACvC,cAAc,2BAA2B,CAAA"}
@@ -11,8 +11,8 @@ var __decorateClass = (decorators, target, key, kind) => {
11
11
  };
12
12
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
13
13
 
14
- // src/AbstractS3PublishRunner.ts
15
- import { PutObjectCommand } from "@aws-sdk/client-s3";
14
+ // src/AbstractS3Provider.ts
15
+ import { GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3";
16
16
  import { assertEx } from "@xylabs/sdk-js";
17
17
  import { AbstractCreatableProvider } from "@xyo-network/xl1-protocol-sdk";
18
18
 
@@ -45,10 +45,10 @@ function decodeBody(body, contentEncoding) {
45
45
  }
46
46
  }
47
47
 
48
- // src/AbstractS3PublishRunner.ts
48
+ // src/AbstractS3Provider.ts
49
49
  var IMMUTABLE_CACHE_CONTROL = "public, max-age=31536000, immutable";
50
50
  var MUTABLE_CACHE_CONTROL = "public, max-age=0, must-revalidate";
51
- var AbstractS3PublishRunner = class extends AbstractCreatableProvider {
51
+ var AbstractS3Provider = class extends AbstractCreatableProvider {
52
52
  get bucket() {
53
53
  return assertEx(this.params.bucket, () => "No bucket specified");
54
54
  }
@@ -61,6 +61,18 @@ var AbstractS3PublishRunner = class extends AbstractCreatableProvider {
61
61
  get prefix() {
62
62
  return this.params.prefix ?? "";
63
63
  }
64
+ /** Reads and decodes a stored JSON file, or undefined when the key does not exist. */
65
+ async getJson(path) {
66
+ try {
67
+ const response = await this.client.send(new GetObjectCommand({ Bucket: this.bucket, Key: `${this.prefix}${path}` }));
68
+ const body = await response.Body?.transformToByteArray();
69
+ if (body === void 0) return void 0;
70
+ return JSON.parse(decodeBody(body, response.ContentEncoding));
71
+ } catch (error) {
72
+ if (isNotFoundError(error)) return void 0;
73
+ throw error;
74
+ }
75
+ }
64
76
  async putJson(path, json, cacheControl) {
65
77
  const { body, contentEncoding } = encodeBody(json, this.contentEncoding);
66
78
  await this.client.send(new PutObjectCommand({
@@ -73,10 +85,19 @@ var AbstractS3PublishRunner = class extends AbstractCreatableProvider {
73
85
  }));
74
86
  }
75
87
  };
88
+ var isNotFoundError = (error) => {
89
+ if (typeof error !== "object" || error === null) return false;
90
+ const { name, $metadata } = error;
91
+ return name === "NoSuchKey" || name === "NotFound" || $metadata?.httpStatusCode === 404;
92
+ };
76
93
 
77
94
  // src/S3BlockPublishRunner.ts
78
95
  import { assertEx as assertEx2, isNull } from "@xylabs/sdk-js";
79
- import { asXL1BlockNumber, BlockPublishRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
96
+ import {
97
+ asXL1BlockNumber,
98
+ BlockPublishRunnerMoniker,
99
+ BlockViewerMoniker
100
+ } from "@xyo-network/xl1-protocol-lib";
80
101
  import { creatableProvider } from "@xyo-network/xl1-protocol-sdk";
81
102
  import {
82
103
  blockHashPath,
@@ -84,8 +105,9 @@ import {
84
105
  payloadPath
85
106
  } from "@xyo-network/xl1-rest-block-viewer";
86
107
  import { Semaphore } from "async-mutex";
87
- var S3BlockPublishRunner = class extends AbstractS3PublishRunner {
108
+ var S3BlockPublishRunner = class extends AbstractS3Provider {
88
109
  moniker = S3BlockPublishRunner.defaultMoniker;
110
+ _source;
89
111
  get concurrency() {
90
112
  return this.params.concurrency ?? 8;
91
113
  }
@@ -93,7 +115,11 @@ var S3BlockPublishRunner = class extends AbstractS3PublishRunner {
93
115
  return this.params.progressInterval ?? 100;
94
116
  }
95
117
  get source() {
96
- return assertEx2(this.params.source, () => "No source specified");
118
+ return assertEx2(this._source, () => "No source specified");
119
+ }
120
+ async createHandler() {
121
+ await super.createHandler();
122
+ this._source = this.params.source ?? await this.locator.getInstance(BlockViewerMoniker);
97
123
  }
98
124
  /** Publishes one block at its by-number and by-hash paths, plus its payload files. */
99
125
  async publishBlock(blockNumber) {
@@ -143,7 +169,7 @@ var S3BlockPublishRunner = class extends AbstractS3PublishRunner {
143
169
  }
144
170
  };
145
171
  __publicField(S3BlockPublishRunner, "defaultMoniker", BlockPublishRunnerMoniker);
146
- __publicField(S3BlockPublishRunner, "dependencies", []);
172
+ __publicField(S3BlockPublishRunner, "dependencies", [BlockViewerMoniker]);
147
173
  __publicField(S3BlockPublishRunner, "monikers", [BlockPublishRunnerMoniker]);
148
174
  S3BlockPublishRunner = __decorateClass([
149
175
  creatableProvider()
@@ -151,13 +177,18 @@ S3BlockPublishRunner = __decorateClass([
151
177
 
152
178
  // src/S3ChainStatePublishRunner.ts
153
179
  import { assertEx as assertEx3 } from "@xylabs/sdk-js";
154
- import { ChainStatePublishRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
180
+ import { BlockViewerMoniker as BlockViewerMoniker2, ChainStatePublishRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
155
181
  import { creatableProvider as creatableProvider2 } from "@xyo-network/xl1-protocol-sdk";
156
182
  import { headPath } from "@xyo-network/xl1-rest-block-viewer";
157
- var S3ChainStatePublishRunner = class extends AbstractS3PublishRunner {
183
+ var S3ChainStatePublishRunner = class extends AbstractS3Provider {
158
184
  moniker = S3ChainStatePublishRunner.defaultMoniker;
185
+ _source;
159
186
  get source() {
160
- return assertEx3(this.params.source, () => "No source specified");
187
+ return assertEx3(this._source, () => "No source specified");
188
+ }
189
+ async createHandler() {
190
+ await super.createHandler();
191
+ this._source = this.params.source ?? await this.locator.getInstance(BlockViewerMoniker2);
161
192
  }
162
193
  /** Publishes the source's current head to the mutable chain state pointer. */
163
194
  async publishHead() {
@@ -168,25 +199,64 @@ var S3ChainStatePublishRunner = class extends AbstractS3PublishRunner {
168
199
  }
169
200
  };
170
201
  __publicField(S3ChainStatePublishRunner, "defaultMoniker", ChainStatePublishRunnerMoniker);
171
- __publicField(S3ChainStatePublishRunner, "dependencies", []);
202
+ __publicField(S3ChainStatePublishRunner, "dependencies", [BlockViewerMoniker2]);
172
203
  __publicField(S3ChainStatePublishRunner, "monikers", [ChainStatePublishRunnerMoniker]);
173
204
  S3ChainStatePublishRunner = __decorateClass([
174
205
  creatableProvider2()
175
206
  ], S3ChainStatePublishRunner);
176
207
 
177
- // src/S3IndexPublishRunner.ts
208
+ // src/S3ChainStateViewer.ts
178
209
  import { assertEx as assertEx4 } from "@xylabs/sdk-js";
210
+ import { asSignedHydratedBlockWithHashMeta, ChainStateViewerMoniker } from "@xyo-network/xl1-protocol-lib";
211
+ import { creatableProvider as creatableProvider3 } from "@xyo-network/xl1-protocol-sdk";
212
+ import { headPath as headPath2 } from "@xyo-network/xl1-rest-block-viewer";
213
+ var S3ChainStateViewer = class extends AbstractS3Provider {
214
+ moniker = S3ChainStateViewer.defaultMoniker;
215
+ /** The published head; throws when no head pointer has been published yet. */
216
+ async currentBlock() {
217
+ return await this.spanAsync("currentBlock", async () => {
218
+ const parsed = assertEx4(await this.getJson(headPath2()), () => "Head not found");
219
+ return asSignedHydratedBlockWithHashMeta(parsed, true);
220
+ }, this.context);
221
+ }
222
+ async currentBlockHash() {
223
+ return (await this.currentBlock())[0]._hash;
224
+ }
225
+ async currentBlockNumber() {
226
+ return (await this.currentBlock())[0].block;
227
+ }
228
+ /** The published head, or undefined when no head pointer has been published yet. */
229
+ async tryCurrentBlock() {
230
+ const parsed = await this.getJson(headPath2());
231
+ return parsed === void 0 ? void 0 : asSignedHydratedBlockWithHashMeta(parsed, true);
232
+ }
233
+ };
234
+ __publicField(S3ChainStateViewer, "defaultMoniker", ChainStateViewerMoniker);
235
+ __publicField(S3ChainStateViewer, "dependencies", []);
236
+ __publicField(S3ChainStateViewer, "monikers", [ChainStateViewerMoniker]);
237
+ S3ChainStateViewer = __decorateClass([
238
+ creatableProvider3()
239
+ ], S3ChainStateViewer);
240
+
241
+ // src/S3IndexPublishRunner.ts
242
+ import { assertEx as assertEx5 } from "@xylabs/sdk-js";
179
243
  import {
180
244
  BlocksStepSummarySchema,
245
+ BlockViewerMoniker as BlockViewerMoniker3,
181
246
  IndexPublishRunnerMoniker,
182
247
  StepSizes
183
248
  } from "@xyo-network/xl1-protocol-lib";
184
- import { blocksMaxStep, creatableProvider as creatableProvider3 } from "@xyo-network/xl1-protocol-sdk";
249
+ import { blocksMaxStep, creatableProvider as creatableProvider4 } from "@xyo-network/xl1-protocol-sdk";
185
250
  import { blocksStepPath } from "@xyo-network/xl1-rest-block-viewer";
186
- var S3IndexPublishRunner = class extends AbstractS3PublishRunner {
251
+ var S3IndexPublishRunner = class extends AbstractS3Provider {
187
252
  moniker = S3IndexPublishRunner.defaultMoniker;
253
+ _source;
188
254
  get source() {
189
- return assertEx4(this.params.source, () => "No source specified");
255
+ return assertEx5(this._source, () => "No source specified");
256
+ }
257
+ async createHandler() {
258
+ await super.createHandler();
259
+ this._source = this.params.source ?? await this.locator.getInstance(BlockViewerMoniker3);
190
260
  }
191
261
  /**
192
262
  * Publishes one completed step's blocks as a BlocksStepSummary file (blocks oldest-first).
@@ -194,15 +264,15 @@ var S3IndexPublishRunner = class extends AbstractS3PublishRunner {
194
264
  */
195
265
  async publishStep(stepLevel, stepIndex) {
196
266
  const size = StepSizes[stepLevel];
197
- assertEx4(stepLevel <= blocksMaxStep, () => `publishStep does not support step levels above ${blocksMaxStep} (requested ${stepLevel})`);
267
+ assertEx5(stepLevel <= blocksMaxStep, () => `publishStep does not support step levels above ${blocksMaxStep} (requested ${stepLevel})`);
198
268
  const lastBlockNumber = (stepIndex + 1) * size - 1;
199
269
  const headNumber = await this.source.currentBlockNumber();
200
- assertEx4(lastBlockNumber <= headNumber, () => `Step ${stepLevel}/${stepIndex} is not complete (head ${headNumber})`);
270
+ assertEx5(lastBlockNumber <= headNumber, () => `Step ${stepLevel}/${stepIndex} is not complete (head ${headNumber})`);
201
271
  const newestFirst = await this.source.blocksByStep(stepLevel, stepIndex);
202
272
  const blocks = newestFirst.toReversed();
203
273
  const summary = {
204
274
  schema: BlocksStepSummarySchema,
205
- hash: assertEx4(blocks.at(-1), () => `No blocks for step ${stepLevel}/${stepIndex}`)[0]._hash,
275
+ hash: assertEx5(blocks.at(-1), () => `No blocks for step ${stepLevel}/${stepIndex}`)[0]._hash,
206
276
  stepSize: size,
207
277
  blocks
208
278
  };
@@ -220,17 +290,18 @@ var S3IndexPublishRunner = class extends AbstractS3PublishRunner {
220
290
  }
221
291
  };
222
292
  __publicField(S3IndexPublishRunner, "defaultMoniker", IndexPublishRunnerMoniker);
223
- __publicField(S3IndexPublishRunner, "dependencies", []);
293
+ __publicField(S3IndexPublishRunner, "dependencies", [BlockViewerMoniker3]);
224
294
  __publicField(S3IndexPublishRunner, "monikers", [IndexPublishRunnerMoniker]);
225
295
  S3IndexPublishRunner = __decorateClass([
226
- creatableProvider3()
296
+ creatableProvider4()
227
297
  ], S3IndexPublishRunner);
228
298
  export {
229
- AbstractS3PublishRunner,
299
+ AbstractS3Provider,
230
300
  IMMUTABLE_CACHE_CONTROL,
231
301
  MUTABLE_CACHE_CONTROL,
232
302
  S3BlockPublishRunner,
233
303
  S3ChainStatePublishRunner,
304
+ S3ChainStateViewer,
234
305
  S3IndexPublishRunner,
235
306
  decodeBody,
236
307
  encodeBody
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/AbstractS3PublishRunner.ts", "../../src/encoding.ts", "../../src/S3BlockPublishRunner.ts", "../../src/S3ChainStatePublishRunner.ts", "../../src/S3IndexPublishRunner.ts"],
4
- "sourcesContent": ["import type { S3Client } from '@aws-sdk/client-s3'\nimport { PutObjectCommand } from '@aws-sdk/client-s3'\nimport { assertEx } from '@xylabs/sdk-js'\nimport type { CreatableProviderParams } from '@xyo-network/xl1-protocol-sdk'\nimport { AbstractCreatableProvider } from '@xyo-network/xl1-protocol-sdk'\n\nimport type { RestContentEncoding } from './encoding.ts'\nimport { encodeBody } from './encoding.ts'\n\n/** Shared parameters for S3 publish runners: where and how published files are written. */\nexport interface S3PublishRunnerParams extends CreatableProviderParams {\n bucket: string\n /** S3-compatible client pointed at the target endpoint (e.g. Cloudflare R2). */\n client: S3Client\n /** Storage/wire encoding for published files. Defaults to 'br' (brotli). */\n contentEncoding?: RestContentEncoding\n /** Optional key prefix, allowing the layout to live in a shared bucket. */\n prefix?: string\n}\n\n/** Finalized files never change once written. */\nexport const IMMUTABLE_CACHE_CONTROL = 'public, max-age=31536000, immutable'\n/** Chain state is rewritten as the chain advances. */\nexport const MUTABLE_CACHE_CONTROL = 'public, max-age=0, must-revalidate'\n\n/**\n * Base for publish runners targeting S3-compatible storage. Bodies are pre-compressed at\n * write time and stored with the matching Content-Encoding plus application/json, so HTTP\n * clients decompress transparently \u2014 keys keep their `.json` extension.\n */\nexport abstract class AbstractS3PublishRunner<TParams extends S3PublishRunnerParams = S3PublishRunnerParams>\n extends AbstractCreatableProvider<TParams> {\n get bucket(): string {\n return assertEx(this.params.bucket, () => 'No bucket specified')\n }\n\n get client(): S3Client {\n return assertEx(this.params.client, () => 'No client specified')\n }\n\n get contentEncoding(): RestContentEncoding {\n return this.params.contentEncoding ?? 'br'\n }\n\n get prefix(): string {\n return this.params.prefix ?? ''\n }\n\n protected async putJson(path: string, json: string, cacheControl: string): Promise<void> {\n const { body, contentEncoding } = encodeBody(json, this.contentEncoding)\n await this.client.send(new PutObjectCommand({\n Bucket: this.bucket,\n Key: `${this.prefix}${path}`,\n Body: body,\n CacheControl: cacheControl,\n ContentEncoding: contentEncoding,\n ContentType: 'application/json',\n }))\n }\n}\n", "import ZLIB from 'node:zlib'\n\n/** Wire/storage encoding for published files. */\nexport type RestContentEncoding = 'br' | 'gzip' | 'none'\n\n/** An encoded file body plus the HTTP Content-Encoding it should be served with. */\nexport interface EncodedBody {\n body: Uint8Array\n contentEncoding?: 'br' | 'gzip'\n}\n\n/**\n * Encodes a JSON string for storage. Bodies are pre-compressed at write time and stored\n * with the matching Content-Encoding so HTTP clients decompress transparently \u2014 keys keep\n * their .json extension and Content-Type stays application/json.\n */\nexport function encodeBody(json: string, encoding: RestContentEncoding): EncodedBody {\n switch (encoding) {\n case 'br': {\n return { body: ZLIB.brotliCompressSync(json), contentEncoding: 'br' }\n }\n case 'gzip': {\n return { body: ZLIB.gzipSync(json), contentEncoding: 'gzip' }\n }\n case 'none': {\n return { body: new TextEncoder().encode(json) }\n }\n }\n}\n\n/** Decodes a stored body back to its JSON string using the object's Content-Encoding. */\nexport function decodeBody(body: Uint8Array, contentEncoding?: string): string {\n switch (contentEncoding) {\n case 'br': {\n return ZLIB.brotliDecompressSync(body).toString('utf8')\n }\n case 'gzip': {\n return ZLIB.gunzipSync(body).toString('utf8')\n }\n default: {\n return new TextDecoder().decode(body)\n }\n }\n}\n", "import { assertEx, isNull } from '@xylabs/sdk-js'\nimport type {\n BlockPublishRunner, BlockViewer, SignedHydratedBlockWithHashMeta, XL1BlockNumber, XL1BlockRange,\n} from '@xyo-network/xl1-protocol-lib'\nimport { asXL1BlockNumber, BlockPublishRunnerMoniker } from '@xyo-network/xl1-protocol-lib'\nimport { creatableProvider } from '@xyo-network/xl1-protocol-sdk'\nimport {\n blockHashPath, blockNumberPath, payloadPath,\n} from '@xyo-network/xl1-rest-block-viewer'\nimport { Semaphore } from 'async-mutex'\n\nimport type { S3PublishRunnerParams } from './AbstractS3PublishRunner.ts'\nimport { AbstractS3PublishRunner, IMMUTABLE_CACHE_CONTROL } from './AbstractS3PublishRunner.ts'\n\n/** A progress event emitted while publishing blocks. */\nexport interface BlockPublishProgress {\n blockNumber: XL1BlockNumber\n published: number\n total: number\n}\n\n/** Parameters for S3BlockPublishRunner. */\nexport interface S3BlockPublishRunnerParams extends S3PublishRunnerParams {\n /** Maximum concurrent block publishes during sync. */\n concurrency?: number\n /**\n * Called every `progressInterval` blocks (and at pass completion). When omitted, the same\n * events are logged via the params logger so long backfills are observable out of the box.\n */\n onProgress?: (event: BlockPublishProgress) => void\n /** How many block publishes between progress reports during sync. */\n progressInterval?: number\n /** The viewer to publish from (only finalized chains should be published). */\n source: BlockViewer\n}\n\n/**\n * Publishes finalized blocks (and their payloads) as the static REST file layout that\n * `RestBlockViewer` reads (see `paths.ts` in @xyo-network/xl1-rest-block-viewer).\n *\n * Publishing is idempotent: keys are deterministic and contents immutable, so re-publishing\n * any range is safe. `sync(from)` resumes from a caller-supplied cursor (typically the block\n * after the last published head); omitting it republishes from genesis, which is safe.\n */\n@creatableProvider()\nexport class S3BlockPublishRunner extends AbstractS3PublishRunner<S3BlockPublishRunnerParams> implements BlockPublishRunner {\n static readonly defaultMoniker = BlockPublishRunnerMoniker\n static readonly dependencies = []\n static readonly monikers = [BlockPublishRunnerMoniker]\n moniker = S3BlockPublishRunner.defaultMoniker\n\n get concurrency(): number {\n return this.params.concurrency ?? 8\n }\n\n get progressInterval(): number {\n return this.params.progressInterval ?? 100\n }\n\n get source(): BlockViewer {\n return assertEx(this.params.source, () => 'No source specified')\n }\n\n /** Publishes one block at its by-number and by-hash paths, plus its payload files. */\n async publishBlock(blockNumber: XL1BlockNumber): Promise<SignedHydratedBlockWithHashMeta | null> {\n const block = await this.source.blockByNumber(blockNumber)\n if (isNull(block)) return null\n const json = JSON.stringify(block)\n await this.putJson(blockNumberPath(block[0].block), json, IMMUTABLE_CACHE_CONTROL)\n await this.putJson(blockHashPath(block[0]._hash), json, IMMUTABLE_CACHE_CONTROL)\n for (const payload of block[1]) {\n await this.putJson(payloadPath(payload._hash), JSON.stringify(payload), IMMUTABLE_CACHE_CONTROL)\n }\n return block\n }\n\n /**\n * Publishes every block from `from` (inclusive, default genesis) through the source head.\n * Returns the published range, or null when already up to date.\n */\n async sync(from: XL1BlockNumber = asXL1BlockNumber(0, true)): Promise<XL1BlockRange | null> {\n const sourceHead = await this.source.currentBlock()\n const end = sourceHead[0].block\n if (from > end) return null\n\n const semaphore = new Semaphore(this.concurrency)\n const numbers = Array.from({ length: end - from + 1 }, (_, i) => asXL1BlockNumber(from + i, true))\n const total = numbers.length\n let publishedCount = 0\n await Promise.all(numbers.map(blockNumber => semaphore.runExclusive(async () => {\n assertEx(await this.publishBlock(blockNumber), () => `Block not found in source [${blockNumber}]`)\n publishedCount += 1\n if (publishedCount % this.progressInterval === 0 || publishedCount === total) {\n this.report({\n blockNumber, published: publishedCount, total,\n })\n }\n })))\n return [from, end]\n }\n\n /** Emits a progress event to the onProgress callback, or logs it when no callback is set. */\n private report(event: BlockPublishProgress): void {\n const onProgress = this.params.onProgress\n if (onProgress) {\n onProgress(event)\n return\n }\n this.logger?.info(`S3BlockPublishRunner: published block ${event.blockNumber} (${event.published}/${event.total})`)\n }\n}\n", "import { assertEx } from '@xylabs/sdk-js'\nimport type {\n ChainStatePublishRunner, ChainStateViewerMethods, SignedHydratedBlockWithHashMeta,\n} from '@xyo-network/xl1-protocol-lib'\nimport { ChainStatePublishRunnerMoniker } from '@xyo-network/xl1-protocol-lib'\nimport { creatableProvider } from '@xyo-network/xl1-protocol-sdk'\nimport { headPath } from '@xyo-network/xl1-rest-block-viewer'\n\nimport type { S3PublishRunnerParams } from './AbstractS3PublishRunner.ts'\nimport { AbstractS3PublishRunner, MUTABLE_CACHE_CONTROL } from './AbstractS3PublishRunner.ts'\n\n/** Parameters for S3ChainStatePublishRunner. */\nexport interface S3ChainStatePublishRunnerParams extends S3PublishRunnerParams {\n /** Where the current head is read from (any BlockViewer satisfies this). */\n source: ChainStateViewerMethods\n}\n\n/**\n * Publishes the mutable chain state \u2014 the head pointer (`chain/head.json`) \u2014 that\n * `RestChainStateViewer` reads. This is the one mutable file in the REST layout, so it is\n * stored with must-revalidate caching and should target the chain-state bucket.\n *\n * Callers must publish the finalized files for a head before publishing the head itself,\n * so readers never see a head that references missing files.\n */\n@creatableProvider()\nexport class S3ChainStatePublishRunner extends AbstractS3PublishRunner<S3ChainStatePublishRunnerParams> implements ChainStatePublishRunner {\n static readonly defaultMoniker = ChainStatePublishRunnerMoniker\n static readonly dependencies = []\n static readonly monikers = [ChainStatePublishRunnerMoniker]\n moniker = S3ChainStatePublishRunner.defaultMoniker\n\n get source(): ChainStateViewerMethods {\n return assertEx(this.params.source, () => 'No source specified')\n }\n\n /** Publishes the source's current head to the mutable chain state pointer. */\n async publishHead(): Promise<SignedHydratedBlockWithHashMeta> {\n const head = await this.source.currentBlock()\n await this.putJson(headPath(), JSON.stringify(head), MUTABLE_CACHE_CONTROL)\n this.logger?.info(`S3ChainStatePublishRunner: published head ${head[0].block}`)\n return head\n }\n}\n", "import { assertEx } from '@xylabs/sdk-js'\nimport type {\n BlocksStepSummary, BlockViewer, IndexPublishRunner, XL1BlockNumber,\n} from '@xyo-network/xl1-protocol-lib'\nimport {\n BlocksStepSummarySchema, IndexPublishRunnerMoniker, StepSizes,\n} from '@xyo-network/xl1-protocol-lib'\nimport { blocksMaxStep, creatableProvider } from '@xyo-network/xl1-protocol-sdk'\nimport { blocksStepPath } from '@xyo-network/xl1-rest-block-viewer'\n\nimport type { S3PublishRunnerParams } from './AbstractS3PublishRunner.ts'\nimport { AbstractS3PublishRunner, IMMUTABLE_CACHE_CONTROL } from './AbstractS3PublishRunner.ts'\n\n/** Parameters for S3IndexPublishRunner. */\nexport interface S3IndexPublishRunnerParams extends S3PublishRunnerParams {\n /** The viewer to publish from (only finalized chains should be published). */\n source: BlockViewer\n}\n\n/**\n * Publishes completed steps' block summaries (the chain index) as the static REST file\n * layout that `RestIndexViewer` reads. Step files are immutable: only complete steps are\n * ever published, and a completed step's blocks never change.\n */\n@creatableProvider()\nexport class S3IndexPublishRunner extends AbstractS3PublishRunner<S3IndexPublishRunnerParams> implements IndexPublishRunner {\n static readonly defaultMoniker = IndexPublishRunnerMoniker\n static readonly dependencies = []\n static readonly monikers = [IndexPublishRunnerMoniker]\n moniker = S3IndexPublishRunner.defaultMoniker\n\n get source(): BlockViewer {\n return assertEx(this.params.source, () => 'No source specified')\n }\n\n /**\n * Publishes one completed step's blocks as a BlocksStepSummary file (blocks oldest-first).\n * Asserts the step is complete \u2014 partial tail steps are never published.\n */\n async publishStep(stepLevel: number, stepIndex: number): Promise<void> {\n const size = StepSizes[stepLevel]\n assertEx(stepLevel <= blocksMaxStep, () => `publishStep does not support step levels above ${blocksMaxStep} (requested ${stepLevel})`)\n const lastBlockNumber = (stepIndex + 1) * size - 1\n const headNumber = await this.source.currentBlockNumber()\n assertEx(lastBlockNumber <= headNumber, () => `Step ${stepLevel}/${stepIndex} is not complete (head ${headNumber})`)\n const newestFirst = await this.source.blocksByStep(stepLevel, stepIndex)\n const blocks = newestFirst.toReversed()\n const summary: BlocksStepSummary = {\n schema: BlocksStepSummarySchema,\n hash: assertEx(blocks.at(-1), () => `No blocks for step ${stepLevel}/${stepIndex}`)[0]._hash,\n stepSize: size,\n blocks,\n }\n await this.putJson(blocksStepPath(stepLevel, stepIndex), JSON.stringify(summary), IMMUTABLE_CACHE_CONTROL)\n this.logger?.info(`S3IndexPublishRunner: published step ${stepLevel}/${stepIndex}`)\n }\n\n /** Publishes every step (at every level) completed by the given block. */\n async publishStepsCompletedBy(blockNumber: XL1BlockNumber): Promise<void> {\n for (let stepLevel = 0; stepLevel <= blocksMaxStep; stepLevel++) {\n const size = StepSizes[stepLevel]\n if ((blockNumber + 1) % size === 0) {\n await this.publishStep(stepLevel, (blockNumber + 1) / size - 1)\n }\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;AACA,SAAS,wBAAwB;AACjC,SAAS,gBAAgB;AAEzB,SAAS,iCAAiC;;;ACJ1C,OAAO,UAA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M,sBAAsB,SAAS,IAAI,SAAS,EAAE,EAAE,CAAC,EAAE;AAAA,MACvF,UAAU;AAAA,MACV;AAAA,IACF;AACA,UAAM,KAAK,QAAQ,eAAe,WAAW,SAAS,GAAG,KAAK,UAAU,OAAO,GAAG,uBAAuB;AACzG,SAAK,QAAQ,KAAK,wCAAwC,SAAS,IAAI,SAAS,EAAE;AAAA,EACpF;AAAA;AAAA,EAGA,MAAM,wBAAwB,aAA4C;AACxE,aAAS,YAAY,GAAG,aAAa,eAAe,aAAa;AAC/D,YAAM,OAAO,UAAU,SAAS;AAChC,WAAK,cAAc,KAAK,SAAS,GAAG;AAClC,cAAM,KAAK,YAAY,YAAY,cAAc,KAAK,OAAO,CAAC;AAAA,MAChE;AAAA,IACF;AAAA,EACF;AACF;AAxCE,cADW,sBACK,kBAAiB;AACjC,cAFW,sBAEK,gBAAe,CAAC;AAChC,cAHW,sBAGK,YAAW,CAAC,yBAAyB;AAH1C,uBAAN;AAAA,EADNC,mBAAkB;AAAA,GACN;",
6
- "names": ["assertEx", "assertEx", "assertEx", "creatableProvider", "assertEx", "creatableProvider", "assertEx", "creatableProvider", "assertEx", "creatableProvider"]
3
+ "sources": ["../../src/AbstractS3Provider.ts", "../../src/encoding.ts", "../../src/S3BlockPublishRunner.ts", "../../src/S3ChainStatePublishRunner.ts", "../../src/S3ChainStateViewer.ts", "../../src/S3IndexPublishRunner.ts"],
4
+ "sourcesContent": ["import type { S3Client } from '@aws-sdk/client-s3'\nimport { GetObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3'\nimport { assertEx } from '@xylabs/sdk-js'\nimport type { CreatableProviderEventData, CreatableProviderParams } from '@xyo-network/xl1-protocol-sdk'\nimport { AbstractCreatableProvider } from '@xyo-network/xl1-protocol-sdk'\n\nimport type { RestContentEncoding } from './encoding.ts'\nimport { decodeBody, encodeBody } from './encoding.ts'\n\n/** Shared parameters for S3-backed providers: where and how files are stored. */\nexport interface S3ProviderParams extends CreatableProviderParams {\n bucket: string\n /** S3-compatible client pointed at the target endpoint (e.g. Cloudflare R2). */\n client: S3Client\n /** Storage/wire encoding for published files. Defaults to 'br' (brotli). */\n contentEncoding?: RestContentEncoding\n /** Optional key prefix, allowing the layout to live in a shared bucket. */\n prefix?: string\n}\n\n/** Finalized files never change once written. */\nexport const IMMUTABLE_CACHE_CONTROL = 'public, max-age=31536000, immutable'\n/** Chain state is rewritten as the chain advances. */\nexport const MUTABLE_CACHE_CONTROL = 'public, max-age=0, must-revalidate'\n\n/**\n * Base for providers targeting S3-compatible storage. Bodies are pre-compressed at write\n * time and stored with the matching Content-Encoding plus application/json, so HTTP clients\n * decompress transparently \u2014 keys keep their `.json` extension. Reads decode the stored\n * Content-Encoding back to JSON.\n */\nexport abstract class AbstractS3Provider<\n TParams extends S3ProviderParams = S3ProviderParams,\n TEventData extends CreatableProviderEventData = CreatableProviderEventData,\n> extends AbstractCreatableProvider<TParams, TEventData> {\n get bucket(): string {\n return assertEx(this.params.bucket, () => 'No bucket specified')\n }\n\n get client(): S3Client {\n return assertEx(this.params.client, () => 'No client specified')\n }\n\n get contentEncoding(): RestContentEncoding {\n return this.params.contentEncoding ?? 'br'\n }\n\n get prefix(): string {\n return this.params.prefix ?? ''\n }\n\n /** Reads and decodes a stored JSON file, or undefined when the key does not exist. */\n protected async getJson(path: string): Promise<unknown> {\n try {\n const response = await this.client.send(new GetObjectCommand({ Bucket: this.bucket, Key: `${this.prefix}${path}` }))\n const body = await response.Body?.transformToByteArray()\n if (body === undefined) return undefined\n return JSON.parse(decodeBody(body, response.ContentEncoding)) as unknown\n } catch (error) {\n if (isNotFoundError(error)) return undefined\n throw error\n }\n }\n\n protected async putJson(path: string, json: string, cacheControl: string): Promise<void> {\n const { body, contentEncoding } = encodeBody(json, this.contentEncoding)\n await this.client.send(new PutObjectCommand({\n Bucket: this.bucket,\n Key: `${this.prefix}${path}`,\n Body: body,\n CacheControl: cacheControl,\n ContentEncoding: contentEncoding,\n ContentType: 'application/json',\n }))\n }\n}\n\nconst isNotFoundError = (error: unknown): boolean => {\n if (typeof error !== 'object' || error === null) return false\n const { name, $metadata } = error as { $metadata?: { httpStatusCode?: number }; name?: string }\n return name === 'NoSuchKey' || name === 'NotFound' || $metadata?.httpStatusCode === 404\n}\n", "import ZLIB from 'node:zlib'\n\n/** Wire/storage encoding for published files. */\nexport type RestContentEncoding = 'br' | 'gzip' | 'none'\n\n/** An encoded file body plus the HTTP Content-Encoding it should be served with. */\nexport interface EncodedBody {\n body: Uint8Array\n contentEncoding?: 'br' | 'gzip'\n}\n\n/**\n * Encodes a JSON string for storage. Bodies are pre-compressed at write time and stored\n * with the matching Content-Encoding so HTTP clients decompress transparently \u2014 keys keep\n * their .json extension and Content-Type stays application/json.\n */\nexport function encodeBody(json: string, encoding: RestContentEncoding): EncodedBody {\n switch (encoding) {\n case 'br': {\n return { body: ZLIB.brotliCompressSync(json), contentEncoding: 'br' }\n }\n case 'gzip': {\n return { body: ZLIB.gzipSync(json), contentEncoding: 'gzip' }\n }\n case 'none': {\n return { body: new TextEncoder().encode(json) }\n }\n }\n}\n\n/** Decodes a stored body back to its JSON string using the object's Content-Encoding. */\nexport function decodeBody(body: Uint8Array, contentEncoding?: string): string {\n switch (contentEncoding) {\n case 'br': {\n return ZLIB.brotliDecompressSync(body).toString('utf8')\n }\n case 'gzip': {\n return ZLIB.gunzipSync(body).toString('utf8')\n }\n default: {\n return new TextDecoder().decode(body)\n }\n }\n}\n", "import { assertEx, isNull } from '@xylabs/sdk-js'\nimport type {\n BlockPublishRunner, BlockViewer, SignedHydratedBlockWithHashMeta, XL1BlockNumber, XL1BlockRange,\n} from '@xyo-network/xl1-protocol-lib'\nimport {\n asXL1BlockNumber, BlockPublishRunnerMoniker, BlockViewerMoniker,\n} from '@xyo-network/xl1-protocol-lib'\nimport { creatableProvider } from '@xyo-network/xl1-protocol-sdk'\nimport {\n blockHashPath, blockNumberPath, payloadPath,\n} from '@xyo-network/xl1-rest-block-viewer'\nimport { Semaphore } from 'async-mutex'\n\nimport type { S3ProviderParams } from './AbstractS3Provider.ts'\nimport { AbstractS3Provider, IMMUTABLE_CACHE_CONTROL } from './AbstractS3Provider.ts'\n\n/** A progress event emitted while publishing blocks. */\nexport interface BlockPublishProgress {\n blockNumber: XL1BlockNumber\n published: number\n total: number\n}\n\n/** Parameters for S3BlockPublishRunner. */\nexport interface S3BlockPublishRunnerParams extends S3ProviderParams {\n /** Maximum concurrent block publishes during sync. */\n concurrency?: number\n /**\n * Called every `progressInterval` blocks (and at pass completion). When omitted, the same\n * events are logged via the params logger so long backfills are observable out of the box.\n */\n onProgress?: (event: BlockPublishProgress) => void\n /** How many block publishes between progress reports during sync. */\n progressInterval?: number\n /**\n * The viewer to publish from (only finalized chains should be published). When omitted,\n * resolved from the locator via BlockViewerMoniker.\n */\n source?: BlockViewer\n}\n\n/**\n * Publishes finalized blocks (and their payloads) as the static REST file layout that\n * `RestBlockViewer` reads (see `paths.ts` in @xyo-network/xl1-rest-block-viewer).\n *\n * Publishing is idempotent: keys are deterministic and contents immutable, so re-publishing\n * any range is safe. `sync(from)` resumes from a caller-supplied cursor (typically the block\n * after the last published head); omitting it republishes from genesis, which is safe.\n */\n@creatableProvider()\nexport class S3BlockPublishRunner extends AbstractS3Provider<S3BlockPublishRunnerParams> implements BlockPublishRunner {\n static readonly defaultMoniker = BlockPublishRunnerMoniker\n static readonly dependencies = [BlockViewerMoniker]\n static readonly monikers = [BlockPublishRunnerMoniker]\n moniker = S3BlockPublishRunner.defaultMoniker\n\n protected _source?: BlockViewer\n\n get concurrency(): number {\n return this.params.concurrency ?? 8\n }\n\n get progressInterval(): number {\n return this.params.progressInterval ?? 100\n }\n\n get source(): BlockViewer {\n return assertEx(this._source, () => 'No source specified')\n }\n\n override async createHandler() {\n await super.createHandler()\n this._source = this.params.source ?? await this.locator.getInstance(BlockViewerMoniker)\n }\n\n /** Publishes one block at its by-number and by-hash paths, plus its payload files. */\n async publishBlock(blockNumber: XL1BlockNumber): Promise<SignedHydratedBlockWithHashMeta | null> {\n const block = await this.source.blockByNumber(blockNumber)\n if (isNull(block)) return null\n const json = JSON.stringify(block)\n await this.putJson(blockNumberPath(block[0].block), json, IMMUTABLE_CACHE_CONTROL)\n await this.putJson(blockHashPath(block[0]._hash), json, IMMUTABLE_CACHE_CONTROL)\n for (const payload of block[1]) {\n await this.putJson(payloadPath(payload._hash), JSON.stringify(payload), IMMUTABLE_CACHE_CONTROL)\n }\n return block\n }\n\n /**\n * Publishes every block from `from` (inclusive, default genesis) through the source head.\n * Returns the published range, or null when already up to date.\n */\n async sync(from: XL1BlockNumber = asXL1BlockNumber(0, true)): Promise<XL1BlockRange | null> {\n const sourceHead = await this.source.currentBlock()\n const end = sourceHead[0].block\n if (from > end) return null\n\n const semaphore = new Semaphore(this.concurrency)\n const numbers = Array.from({ length: end - from + 1 }, (_, i) => asXL1BlockNumber(from + i, true))\n const total = numbers.length\n let publishedCount = 0\n await Promise.all(numbers.map(blockNumber => semaphore.runExclusive(async () => {\n assertEx(await this.publishBlock(blockNumber), () => `Block not found in source [${blockNumber}]`)\n publishedCount += 1\n if (publishedCount % this.progressInterval === 0 || publishedCount === total) {\n this.report({\n blockNumber, published: publishedCount, total,\n })\n }\n })))\n return [from, end]\n }\n\n /** Emits a progress event to the onProgress callback, or logs it when no callback is set. */\n private report(event: BlockPublishProgress): void {\n const onProgress = this.params.onProgress\n if (onProgress) {\n onProgress(event)\n return\n }\n this.logger?.info(`S3BlockPublishRunner: published block ${event.blockNumber} (${event.published}/${event.total})`)\n }\n}\n", "import { assertEx } from '@xylabs/sdk-js'\nimport type {\n BlockViewer,\n ChainStatePublishRunner, ChainStateViewerMethods, SignedHydratedBlockWithHashMeta,\n} from '@xyo-network/xl1-protocol-lib'\nimport { BlockViewerMoniker, ChainStatePublishRunnerMoniker } from '@xyo-network/xl1-protocol-lib'\nimport { creatableProvider } from '@xyo-network/xl1-protocol-sdk'\nimport { headPath } from '@xyo-network/xl1-rest-block-viewer'\n\nimport type { S3ProviderParams } from './AbstractS3Provider.ts'\nimport { AbstractS3Provider, MUTABLE_CACHE_CONTROL } from './AbstractS3Provider.ts'\n\n/** Parameters for S3ChainStatePublishRunner. */\nexport interface S3ChainStatePublishRunnerParams extends S3ProviderParams {\n /**\n * Where the current head is read from (any BlockViewer satisfies this). When omitted,\n * resolved from the locator via BlockViewerMoniker.\n */\n source?: ChainStateViewerMethods\n}\n\n/**\n * Publishes the mutable chain state \u2014 the head pointer (`chain/head.json`) \u2014 that\n * `RestChainStateViewer` reads. This is the one mutable file in the REST layout, so it is\n * stored with must-revalidate caching and should target the chain-state bucket.\n *\n * Callers must publish the finalized files for a head before publishing the head itself,\n * so readers never see a head that references missing files.\n */\n@creatableProvider()\nexport class S3ChainStatePublishRunner extends AbstractS3Provider<S3ChainStatePublishRunnerParams> implements ChainStatePublishRunner {\n static readonly defaultMoniker = ChainStatePublishRunnerMoniker\n static readonly dependencies = [BlockViewerMoniker]\n static readonly monikers = [ChainStatePublishRunnerMoniker]\n moniker = S3ChainStatePublishRunner.defaultMoniker\n\n protected _source?: ChainStateViewerMethods\n\n get source(): ChainStateViewerMethods {\n return assertEx(this._source, () => 'No source specified')\n }\n\n override async createHandler() {\n await super.createHandler()\n this._source = this.params.source ?? await this.locator.getInstance<BlockViewer>(BlockViewerMoniker)\n }\n\n /** Publishes the source's current head to the mutable chain state pointer. */\n async publishHead(): Promise<SignedHydratedBlockWithHashMeta> {\n const head = await this.source.currentBlock()\n await this.putJson(headPath(), JSON.stringify(head), MUTABLE_CACHE_CONTROL)\n this.logger?.info(`S3ChainStatePublishRunner: published head ${head[0].block}`)\n return head\n }\n}\n", "import type { Hash } from '@xylabs/sdk-js'\nimport { assertEx } from '@xylabs/sdk-js'\nimport type {\n ChainStateViewer, SignedHydratedBlockWithHashMeta, XL1BlockNumber,\n} from '@xyo-network/xl1-protocol-lib'\nimport { asSignedHydratedBlockWithHashMeta, ChainStateViewerMoniker } from '@xyo-network/xl1-protocol-lib'\nimport { creatableProvider } from '@xyo-network/xl1-protocol-sdk'\nimport { headPath } from '@xyo-network/xl1-rest-block-viewer'\n\nimport type { S3ProviderParams } from './AbstractS3Provider.ts'\nimport { AbstractS3Provider } from './AbstractS3Provider.ts'\n\n/** Parameters for S3ChainStateViewer. */\nexport interface S3ChainStateViewerParams extends S3ProviderParams {}\n\n/**\n * A ChainStateViewer over the chain-state bucket, reading the published head pointer back\n * through the S3 API (authenticated, not the public HTTP layout \u2014 see RestChainStateViewer\n * for anonymous reads). This is how publishers learn their resume cursor: the head pointer\n * is only written after the finalized files it references exist.\n */\n@creatableProvider()\nexport class S3ChainStateViewer extends AbstractS3Provider<S3ChainStateViewerParams, ChainStateViewer['eventData']>\n implements ChainStateViewer {\n static readonly defaultMoniker = ChainStateViewerMoniker\n static readonly dependencies = []\n static readonly monikers = [ChainStateViewerMoniker]\n moniker = S3ChainStateViewer.defaultMoniker\n\n /** The published head; throws when no head pointer has been published yet. */\n async currentBlock(): Promise<SignedHydratedBlockWithHashMeta> {\n return await this.spanAsync('currentBlock', async () => {\n const parsed = assertEx(await this.getJson(headPath()), () => 'Head not found')\n return asSignedHydratedBlockWithHashMeta(parsed, true)\n }, this.context)\n }\n\n async currentBlockHash(): Promise<Hash> {\n return (await this.currentBlock())[0]._hash\n }\n\n async currentBlockNumber(): Promise<XL1BlockNumber> {\n return (await this.currentBlock())[0].block\n }\n\n /** The published head, or undefined when no head pointer has been published yet. */\n async tryCurrentBlock(): Promise<SignedHydratedBlockWithHashMeta | undefined> {\n const parsed = await this.getJson(headPath())\n return parsed === undefined ? undefined : asSignedHydratedBlockWithHashMeta(parsed, true)\n }\n}\n", "import { assertEx } from '@xylabs/sdk-js'\nimport type {\n BlocksStepSummary, BlockViewer, IndexPublishRunner, XL1BlockNumber,\n} from '@xyo-network/xl1-protocol-lib'\nimport {\n BlocksStepSummarySchema, BlockViewerMoniker, IndexPublishRunnerMoniker, StepSizes,\n} from '@xyo-network/xl1-protocol-lib'\nimport { blocksMaxStep, creatableProvider } from '@xyo-network/xl1-protocol-sdk'\nimport { blocksStepPath } from '@xyo-network/xl1-rest-block-viewer'\n\nimport type { S3ProviderParams } from './AbstractS3Provider.ts'\nimport { AbstractS3Provider, IMMUTABLE_CACHE_CONTROL } from './AbstractS3Provider.ts'\n\n/** Parameters for S3IndexPublishRunner. */\nexport interface S3IndexPublishRunnerParams extends S3ProviderParams {\n /**\n * The viewer to publish from (only finalized chains should be published). When omitted,\n * resolved from the locator via BlockViewerMoniker.\n */\n source?: BlockViewer\n}\n\n/**\n * Publishes completed steps' block summaries (the chain index) as the static REST file\n * layout that `RestIndexViewer` reads. Step files are immutable: only complete steps are\n * ever published, and a completed step's blocks never change.\n */\n@creatableProvider()\nexport class S3IndexPublishRunner extends AbstractS3Provider<S3IndexPublishRunnerParams> implements IndexPublishRunner {\n static readonly defaultMoniker = IndexPublishRunnerMoniker\n static readonly dependencies = [BlockViewerMoniker]\n static readonly monikers = [IndexPublishRunnerMoniker]\n moniker = S3IndexPublishRunner.defaultMoniker\n\n protected _source?: BlockViewer\n\n get source(): BlockViewer {\n return assertEx(this._source, () => 'No source specified')\n }\n\n override async createHandler() {\n await super.createHandler()\n this._source = this.params.source ?? await this.locator.getInstance(BlockViewerMoniker)\n }\n\n /**\n * Publishes one completed step's blocks as a BlocksStepSummary file (blocks oldest-first).\n * Asserts the step is complete \u2014 partial tail steps are never published.\n */\n async publishStep(stepLevel: number, stepIndex: number): Promise<void> {\n const size = StepSizes[stepLevel]\n assertEx(stepLevel <= blocksMaxStep, () => `publishStep does not support step levels above ${blocksMaxStep} (requested ${stepLevel})`)\n const lastBlockNumber = (stepIndex + 1) * size - 1\n const headNumber = await this.source.currentBlockNumber()\n assertEx(lastBlockNumber <= headNumber, () => `Step ${stepLevel}/${stepIndex} is not complete (head ${headNumber})`)\n const newestFirst = await this.source.blocksByStep(stepLevel, stepIndex)\n const blocks = newestFirst.toReversed()\n const summary: BlocksStepSummary = {\n schema: BlocksStepSummarySchema,\n hash: assertEx(blocks.at(-1), () => `No blocks for step ${stepLevel}/${stepIndex}`)[0]._hash,\n stepSize: size,\n blocks,\n }\n await this.putJson(blocksStepPath(stepLevel, stepIndex), JSON.stringify(summary), IMMUTABLE_CACHE_CONTROL)\n this.logger?.info(`S3IndexPublishRunner: published step ${stepLevel}/${stepIndex}`)\n }\n\n /** Publishes every step (at every level) completed by the given block. */\n async publishStepsCompletedBy(blockNumber: XL1BlockNumber): Promise<void> {\n for (let stepLevel = 0; stepLevel <= blocksMaxStep; stepLevel++) {\n const size = StepSizes[stepLevel]\n if ((blockNumber + 1) % size === 0) {\n await this.publishStep(stepLevel, (blockNumber + 1) / size - 1)\n }\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AACA,SAAS,kBAAkB,wBAAwB;AACnD,SAAS,gBAAgB;AAEzB,SAAS,iCAAiC;;;ACJ1C,OAAO,UAAU;AAgBV,SAAS,WAAW,MAAc,UAA4C;AACnF,UAAQ,UAAU;AAAA,IAChB,KAAK,MAAM;AACT,aAAO,EAAE,MAAM,KAAK,mBAAmB,IAAI,GAAG,iBAAiB,KAAK;AAAA,IACtE;AAAA,IACA,KAAK,QAAQ;AACX,aAAO,EAAE,MAAM,KAAK,SAAS,IAAI,GAAG,iBAAiB,OAAO;AAAA,IAC9D;AAAA,IACA,KAAK,QAAQ;AACX,aAAO,EAAE,MAAM,IAAI,YAAY,EAAE,OAAO,IAAI,EAAE;AAAA,IAChD;AAAA,EACF;AACF;AAGO,SAAS,WAAW,MAAkB,iBAAkC;AAC7E,UAAQ,iBAAiB;AAAA,IACvB,KAAK,MAAM;AACT,aAAO,KAAK,qBAAqB,IAAI,EAAE,SAAS,MAAM;AAAA,IACxD;AAAA,IACA,KAAK,QAAQ;AACX,aAAO,KAAK,WAAW,IAAI,EAAE,SAAS,MAAM;AAAA,IAC9C;AAAA,IACA,SAAS;AACP,aAAO,IAAI,YAAY,EAAE,OAAO,IAAI;AAAA,IACtC;AAAA,EACF;AACF;;;ADtBO,IAAM,0BA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AA,MACR,MAAMA,UAAS,OAAO,GAAG,EAAE,GAAG,MAAM,sBAAsB,SAAS,IAAI,SAAS,EAAE,EAAE,CAAC,EAAE;AAAA,MACvF,UAAU;AAAA,MACV;AAAA,IACF;AACA,UAAM,KAAK,QAAQ,eAAe,WAAW,SAAS,GAAG,KAAK,UAAU,OAAO,GAAG,uBAAuB;AACzG,SAAK,QAAQ,KAAK,wCAAwC,SAAS,IAAI,SAAS,EAAE;AAAA,EACpF;AAAA;AAAA,EAGA,MAAM,wBAAwB,aAA4C;AACxE,aAAS,YAAY,GAAG,aAAa,eAAe,aAAa;AAC/D,YAAM,OAAO,UAAU,SAAS;AAChC,WAAK,cAAc,KAAK,SAAS,GAAG;AAClC,cAAM,KAAK,YAAY,YAAY,cAAc,KAAK,OAAO,CAAC;AAAA,MAChE;AAAA,IACF;AAAA,EACF;AACF;AA/CE,cADW,sBACK,kBAAiB;AACjC,cAFW,sBAEK,gBAAe,CAACC,mBAAkB;AAClD,cAHW,sBAGK,YAAW,CAAC,yBAAyB;AAH1C,uBAAN;AAAA,EADNC,mBAAkB;AAAA,GACN;",
6
+ "names": ["assertEx", "assertEx", "assertEx", "BlockViewerMoniker", "creatableProvider", "assertEx", "BlockViewerMoniker", "creatableProvider", "assertEx", "creatableProvider", "headPath", "assertEx", "headPath", "creatableProvider", "assertEx", "BlockViewerMoniker", "creatableProvider", "assertEx", "BlockViewerMoniker", "creatableProvider"]
7
7
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json.schemastore.org/package.json",
3
3
  "name": "@xyo-network/xl1-rest-block-publisher",
4
- "version": "2.1.3",
4
+ "version": "2.1.4",
5
5
  "description": "XYO Layer One static REST chain layout publisher",
6
6
  "homepage": "https://xylabs.com",
7
7
  "bugs": {
@@ -35,12 +35,12 @@
35
35
  "README.md"
36
36
  ],
37
37
  "dependencies": {
38
- "@xyo-network/xl1-protocol-lib": "~2.1.3",
39
- "@xyo-network/xl1-protocol-sdk": "~2.1.3",
40
- "@xyo-network/xl1-rest-block-viewer": "~2.1.3"
38
+ "@xyo-network/xl1-protocol-lib": "~2.1.4",
39
+ "@xyo-network/xl1-protocol-sdk": "~2.1.4",
40
+ "@xyo-network/xl1-rest-block-viewer": "~2.1.4"
41
41
  },
42
42
  "devDependencies": {
43
- "@aws-sdk/client-s3": "^3.1065.0",
43
+ "@aws-sdk/client-s3": "^3.1066.0",
44
44
  "@bitauth/libauth": "~3.0.0",
45
45
  "@metamask/providers": "^22.1.1",
46
46
  "@noble/post-quantum": "~0.6.1",
@@ -48,18 +48,16 @@
48
48
  "@opentelemetry/sdk-trace-base": "^2.7.1",
49
49
  "@scure/base": "~2.2.0",
50
50
  "@scure/bip39": "~2.2.0",
51
- "@xylabs/geo": "^6.1.0",
52
- "@xylabs/sdk-js": "^6.1.0",
53
- "@xylabs/threads": "~6.1",
51
+ "@xylabs/geo": "^6.1.1",
52
+ "@xylabs/sdk-js": "^6.1.1",
53
+ "@xylabs/threads": "^6.1.1",
54
54
  "@xylabs/toolchain": "~8.1.20",
55
55
  "@xylabs/tsconfig": "~8.1.20",
56
- "@xyo-network/address": "^6.0.9",
57
- "@xyo-network/sdk-js": "^6.0.4",
58
- "@xyo-network/sdk-protocol-js": "~6.0.9",
56
+ "@xyo-network/address": "^6.1.0",
57
+ "@xyo-network/sdk-js": "^6.1.0",
58
+ "@xyo-network/sdk-protocol-js": "~6.1",
59
59
  "ajv": "^8.20.0",
60
60
  "async-mutex": "^0.5.0",
61
- "bn.js": "^5.2.3",
62
- "buffer": "^6.0.3",
63
61
  "cosmiconfig": "^9.0.2",
64
62
  "debug": "~4.4.3",
65
63
  "eslint": "^10.4.1",
@@ -88,11 +86,9 @@
88
86
  "@xylabs/threads": "^6.1",
89
87
  "@xyo-network/address": "^6.0",
90
88
  "@xyo-network/sdk-js": "^6.0",
91
- "@xyo-network/sdk-protocol-js": "~6.0",
89
+ "@xyo-network/sdk-protocol-js": "~6.1",
92
90
  "ajv": "^8.20",
93
91
  "async-mutex": "^0.5",
94
- "bn.js": "^5.2",
95
- "buffer": "^6.0",
96
92
  "cosmiconfig": "^9.0",
97
93
  "debug": "~4.4",
98
94
  "ethers": "^6.16",
@@ -1 +0,0 @@
1
- {"version":3,"file":"AbstractS3PublishRunner.d.ts","sourceRoot":"","sources":["../../src/AbstractS3PublishRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAGlD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAA;AAEzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAGxD,2FAA2F;AAC3F,MAAM,WAAW,qBAAsB,SAAQ,uBAAuB;IACpE,MAAM,EAAE,MAAM,CAAA;IACd,gFAAgF;IAChF,MAAM,EAAE,QAAQ,CAAA;IAChB,4EAA4E;IAC5E,eAAe,CAAC,EAAE,mBAAmB,CAAA;IACrC,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,iDAAiD;AACjD,eAAO,MAAM,uBAAuB,wCAAwC,CAAA;AAC5E,sDAAsD;AACtD,eAAO,MAAM,qBAAqB,uCAAuC,CAAA;AAEzE;;;;GAIG;AACH,8BAAsB,uBAAuB,CAAC,OAAO,SAAS,qBAAqB,GAAG,qBAAqB,CACzG,SAAQ,yBAAyB,CAAC,OAAO,CAAC;IAC1C,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,IAAI,QAAQ,CAErB;IAED,IAAI,eAAe,IAAI,mBAAmB,CAEzC;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;cAEe,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWzF"}