apibara 2.1.0-beta.4 → 2.1.0-beta.41

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.
Files changed (119) hide show
  1. package/dist/chunks/add.mjs +16 -8
  2. package/dist/chunks/add.mjs.map +1 -0
  3. package/dist/chunks/build.mjs +4 -2
  4. package/dist/chunks/build.mjs.map +1 -0
  5. package/dist/chunks/dev.mjs +55 -21
  6. package/dist/chunks/dev.mjs.map +1 -0
  7. package/dist/chunks/init.mjs +11 -7
  8. package/dist/chunks/init.mjs.map +1 -0
  9. package/dist/chunks/prepare.mjs +4 -2
  10. package/dist/chunks/prepare.mjs.map +1 -0
  11. package/dist/chunks/start.mjs +16 -4
  12. package/dist/chunks/start.mjs.map +1 -0
  13. package/dist/chunks/write-project-info.mjs +51 -0
  14. package/dist/chunks/write-project-info.mjs.map +1 -0
  15. package/dist/cli/index.mjs +3 -1
  16. package/dist/cli/index.mjs.map +1 -0
  17. package/dist/common/index.d.mts +33 -0
  18. package/dist/common/index.d.ts +33 -0
  19. package/dist/common/index.mjs +91 -0
  20. package/dist/common/index.mjs.map +1 -0
  21. package/dist/config/index.mjs +1 -0
  22. package/dist/config/index.mjs.map +1 -0
  23. package/dist/core/index.mjs +134 -69
  24. package/dist/core/index.mjs.map +1 -0
  25. package/dist/create/index.d.mts +2 -1
  26. package/dist/create/index.d.ts +2 -1
  27. package/dist/create/index.mjs +168 -139
  28. package/dist/create/index.mjs.map +1 -0
  29. package/dist/hooks/index.mjs +6 -1
  30. package/dist/hooks/index.mjs.map +1 -0
  31. package/dist/indexer/index.d.ts +1 -0
  32. package/dist/indexer/index.mjs +1 -0
  33. package/dist/indexer/plugins.d.ts +1 -0
  34. package/dist/indexer/plugins.mjs +1 -0
  35. package/dist/indexer/testing.d.ts +1 -0
  36. package/dist/indexer/testing.mjs +1 -0
  37. package/dist/indexer/vcr.d.ts +1 -0
  38. package/dist/indexer/vcr.mjs +1 -0
  39. package/dist/rolldown/index.d.mts +7 -0
  40. package/dist/rolldown/index.d.ts +7 -0
  41. package/dist/rolldown/index.mjs +141 -0
  42. package/dist/rolldown/index.mjs.map +1 -0
  43. package/dist/runtime/dev.mjs +39 -17
  44. package/dist/runtime/internal/app.d.ts +14 -1
  45. package/dist/runtime/internal/app.mjs +26 -21
  46. package/dist/runtime/project-info.d.ts +3 -0
  47. package/dist/runtime/project-info.mjs +67 -0
  48. package/dist/runtime/start.mjs +78 -11
  49. package/dist/shared/apibara.730bb1e4.mjs +18 -0
  50. package/dist/shared/apibara.730bb1e4.mjs.map +1 -0
  51. package/dist/types/index.d.mts +24 -20
  52. package/dist/types/index.d.ts +24 -20
  53. package/dist/types/index.mjs +1 -0
  54. package/dist/types/index.mjs.map +1 -0
  55. package/package.json +33 -16
  56. package/src/cli/commands/add.ts +16 -7
  57. package/src/cli/commands/build.ts +5 -2
  58. package/src/cli/commands/dev.ts +64 -20
  59. package/src/cli/commands/init.ts +12 -7
  60. package/src/cli/commands/prepare.ts +4 -3
  61. package/src/cli/commands/start.ts +18 -3
  62. package/src/cli/commands/write-project-info.ts +56 -0
  63. package/src/cli/index.ts +2 -0
  64. package/src/common/cli.ts +40 -0
  65. package/src/common/constants.ts +6 -0
  66. package/src/common/helper.ts +86 -0
  67. package/src/common/index.ts +3 -0
  68. package/src/core/apibara.ts +7 -2
  69. package/src/core/build/build.ts +13 -5
  70. package/src/core/build/dev.ts +46 -23
  71. package/src/core/build/error.ts +9 -14
  72. package/src/core/build/prepare.ts +5 -3
  73. package/src/core/build/prod.ts +25 -16
  74. package/src/core/build/types.ts +11 -1
  75. package/src/core/config/defaults.ts +3 -0
  76. package/src/core/config/loader.ts +15 -7
  77. package/src/core/config/resolvers/runtime.resolver.ts +44 -0
  78. package/src/core/config/update.ts +6 -2
  79. package/src/core/scan.ts +1 -1
  80. package/src/create/add.ts +14 -20
  81. package/src/create/constants.ts +5 -7
  82. package/src/create/init.ts +8 -5
  83. package/src/create/templates.ts +144 -116
  84. package/src/create/types.ts +3 -0
  85. package/src/create/utils.ts +20 -7
  86. package/src/hooks/useRuntimeConfig.ts +4 -1
  87. package/src/indexer/index.ts +1 -0
  88. package/src/indexer/plugins.ts +1 -0
  89. package/src/indexer/testing.ts +1 -0
  90. package/src/indexer/vcr.ts +1 -0
  91. package/src/rolldown/config.ts +86 -0
  92. package/src/rolldown/index.ts +2 -0
  93. package/src/{rollup → rolldown}/plugins/indexers.ts +3 -3
  94. package/src/rolldown/plugins/instrumentation.ts +68 -0
  95. package/src/rolldown/plugins/static-config.ts +21 -0
  96. package/src/runtime/dev.ts +49 -19
  97. package/src/runtime/internal/app.ts +42 -29
  98. package/src/runtime/project-info.ts +90 -0
  99. package/src/runtime/start.ts +91 -11
  100. package/src/types/config.ts +27 -13
  101. package/src/types/hooks.ts +8 -5
  102. package/src/types/index.ts +1 -1
  103. package/src/types/rolldown.ts +5 -0
  104. package/src/types/virtual/indexers.d.ts +4 -1
  105. package/src/types/virtual/instrumentation.d.ts +4 -0
  106. package/src/types/virtual/static-config.d.ts +4 -0
  107. package/dist/rollup/index.d.mts +0 -6
  108. package/dist/rollup/index.d.ts +0 -6
  109. package/dist/rollup/index.mjs +0 -150
  110. package/dist/shared/apibara.1b515d04.mjs +0 -8
  111. package/src/cli/common.ts +0 -8
  112. package/src/core/config/resolvers/preset.resolver.ts +0 -9
  113. package/src/core/config/resolvers/runtime-config.resolver.ts +0 -6
  114. package/src/rollup/config.ts +0 -87
  115. package/src/rollup/index.ts +0 -2
  116. package/src/rollup/plugins/config.ts +0 -12
  117. package/src/rollup/plugins/esm-shim.ts +0 -69
  118. package/src/types/rollup.ts +0 -8
  119. package/src/types/virtual/config.d.ts +0 -3
@@ -0,0 +1,21 @@
1
+ import virtual from "@rollup/plugin-virtual";
2
+ import { USER_ENV_APIBARA_RUNTIME_CONFIG } from "apibara/common";
3
+ import type { Apibara } from "apibara/types";
4
+ import type { RolldownPluginOption } from "rolldown";
5
+
6
+ export function staticConfig(apibara: Apibara) {
7
+ const presetString = apibara.options.preset ?? "";
8
+ const presetsStringified = JSON.stringify(apibara.options.presets ?? {});
9
+ const runtimeConfigStringified = JSON.stringify(
10
+ apibara.options.runtimeConfig ?? {},
11
+ );
12
+
13
+ return virtual({
14
+ "#apibara-internal-virtual/static-config": `
15
+ export const preset = ${presetString ? `"${presetString}"` : "undefined"};
16
+ export const presets = ${presetsStringified};
17
+ export const runtimeConfig = ${runtimeConfigStringified};
18
+ export const userEnvRuntimeConfig = JSON.parse(process.env.${USER_ENV_APIBARA_RUNTIME_CONFIG} ?? "{}");
19
+ `,
20
+ }) as RolldownPluginOption;
21
+ }
@@ -1,8 +1,53 @@
1
- import { runWithReconnect } from "@apibara/indexer";
2
- import { createClient } from "@apibara/protocol";
1
+ import { ReloadIndexerRequest, runWithReconnect } from "@apibara/indexer";
2
+ import { createAuthenticatedClient } from "@apibara/protocol";
3
+ import { getRuntimeDataFromEnv } from "apibara/common";
3
4
  import { defineCommand, runMain } from "citty";
5
+ import type { ConsolaInstance } from "consola";
6
+ import { blueBright } from "picocolors";
4
7
  import { availableIndexers, createIndexer } from "./internal/app";
5
8
 
9
+ async function startIndexer(indexer: string) {
10
+ let _logger: ConsolaInstance | undefined;
11
+ while (true) {
12
+ try {
13
+ const { processedRuntimeConfig, preset } = getRuntimeDataFromEnv();
14
+
15
+ const { indexer: indexerInstance, logger } =
16
+ (await createIndexer({
17
+ indexerName: indexer,
18
+ processedRuntimeConfig,
19
+ preset,
20
+ })) ?? {};
21
+
22
+ _logger = logger;
23
+
24
+ if (!indexerInstance) {
25
+ return;
26
+ }
27
+
28
+ const client = createAuthenticatedClient(
29
+ indexerInstance.streamConfig,
30
+ indexerInstance.options.streamUrl,
31
+ indexerInstance.options.clientOptions,
32
+ );
33
+
34
+ if (logger) {
35
+ logger.info(`Indexer ${blueBright(indexer)} started`);
36
+ }
37
+
38
+ await runWithReconnect(client, indexerInstance);
39
+
40
+ return;
41
+ } catch (error) {
42
+ if (error instanceof ReloadIndexerRequest) {
43
+ _logger?.info(`Indexer ${blueBright(indexer)} reloaded`);
44
+ continue;
45
+ }
46
+ throw error;
47
+ }
48
+ }
49
+ }
50
+
6
51
  const startCommand = defineCommand({
7
52
  meta: {
8
53
  name: "start",
@@ -13,13 +58,9 @@ const startCommand = defineCommand({
13
58
  type: "string",
14
59
  description: "Which indexers to run",
15
60
  },
16
- preset: {
17
- type: "string",
18
- description: "Preset to use",
19
- },
20
61
  },
21
62
  async run({ args }) {
22
- const { indexers: indexersArgs, preset } = args;
63
+ const { indexers: indexersArgs } = args;
23
64
 
24
65
  let selectedIndexers = availableIndexers;
25
66
  if (indexersArgs) {
@@ -34,18 +75,7 @@ const startCommand = defineCommand({
34
75
  }
35
76
  }
36
77
 
37
- await Promise.all(
38
- selectedIndexers.map(async (indexer) => {
39
- const indexerInstance = createIndexer(indexer, preset);
40
-
41
- const client = createClient(
42
- indexerInstance.streamConfig,
43
- indexerInstance.options.streamUrl,
44
- );
45
-
46
- await runWithReconnect(client, indexerInstance);
47
- }),
48
- );
78
+ await Promise.all(selectedIndexers.map((indexer) => startIndexer(indexer)));
49
79
  },
50
80
  });
51
81
 
@@ -8,32 +8,28 @@ import {
8
8
  inMemoryPersistence,
9
9
  logger,
10
10
  } from "@apibara/indexer/plugins";
11
- import { config } from "#apibara-internal-virtual/config";
11
+ import consola from "consola";
12
12
  import { indexers } from "#apibara-internal-virtual/indexers";
13
+ import { logger as instrumentationLogger } from "#apibara-internal-virtual/instrumentation";
13
14
  import { createLogger } from "./logger";
14
15
 
15
16
  export const availableIndexers = indexers.map((i) => i.name);
16
17
 
17
- export function createIndexer(indexerName: string, preset?: string) {
18
- let runtimeConfig: Record<string, unknown> = { ...config.runtimeConfig };
19
-
20
- if (preset) {
21
- if (config.presets === undefined) {
22
- throw new Error(
23
- `Specified preset "${preset}" but no presets were defined`,
24
- );
25
- }
26
-
27
- if (config.presets[preset] === undefined) {
28
- throw new Error(`Specified preset "${preset}" but it was not defined`);
29
- }
30
-
31
- const presetValue = config.presets[preset] as {
32
- runtimeConfig: Record<string, unknown>;
33
- };
34
- runtimeConfig = { ...runtimeConfig, ...presetValue.runtimeConfig };
35
- }
36
-
18
+ export async function createIndexer({
19
+ indexerName,
20
+ processedRuntimeConfig,
21
+ preset,
22
+ }: {
23
+ indexerName: string;
24
+ /**
25
+ * Final processed runtime config to be used by the indexer
26
+ */
27
+ processedRuntimeConfig: Record<string, unknown>;
28
+ /**
29
+ * Preset name which was used to generate the runtime config
30
+ */
31
+ preset?: string;
32
+ }) {
37
33
  const indexerDefinition = indexers.find((i) => i.name === indexerName);
38
34
 
39
35
  if (indexerDefinition === undefined) {
@@ -42,10 +38,18 @@ export function createIndexer(indexerName: string, preset?: string) {
42
38
  );
43
39
  }
44
40
 
41
+ const indexerModule = indexerDefinition.indexer?.default;
42
+ if (indexerModule === undefined) {
43
+ consola.warn(
44
+ `Specified indexer "${indexerName}" but it does not export a default. Ignoring.`,
45
+ );
46
+ return;
47
+ }
48
+
45
49
  const definition =
46
- typeof indexerDefinition.indexer === "function"
47
- ? indexerDefinition.indexer(runtimeConfig)
48
- : indexerDefinition.indexer;
50
+ typeof indexerModule === "function"
51
+ ? await indexerModule(processedRuntimeConfig)
52
+ : indexerModule;
49
53
 
50
54
  let reporter: ConsolaReporter = createLogger({
51
55
  indexer: indexerName,
@@ -53,26 +57,35 @@ export function createIndexer(indexerName: string, preset?: string) {
53
57
  indexers: availableIndexers,
54
58
  });
55
59
 
56
- if (config.logger) {
57
- reporter = config.logger({
60
+ // Check if a custom logger is provided through instrumentation
61
+ if (instrumentationLogger) {
62
+ // Create a reporter using the custom logger function
63
+ const _reporter = instrumentationLogger({
58
64
  indexer: indexerName,
59
65
  preset,
60
66
  indexers: availableIndexers,
61
67
  });
68
+
69
+ // If the reporter is valid (has a log method), use it instead of the default
70
+ if (_reporter && "log" in _reporter) {
71
+ reporter = _reporter;
72
+ }
62
73
  }
63
74
 
64
75
  // Put the in-memory persistence plugin first so that it can be overridden by any user-defined
65
76
  // persistence plugin.
66
- // Put the logger last since we want to override any user-defined logger.
67
77
  definition.plugins = [
68
78
  internalContext({
69
79
  indexerName,
70
80
  availableIndexers,
71
81
  } as InternalContext),
82
+ logger({ logger: reporter }),
72
83
  inMemoryPersistence(),
73
84
  ...(definition.plugins ?? []),
74
- logger({ logger: reporter }),
75
85
  ];
76
86
 
77
- return _createIndexer(definition);
87
+ return {
88
+ indexer: _createIndexer(definition),
89
+ logger: consola.create({ reporters: [reporter] }),
90
+ };
78
91
  }
@@ -0,0 +1,90 @@
1
+ import { writeFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import {
4
+ getProcessedRuntimeConfig,
5
+ getRuntimeDataFromEnv,
6
+ } from "apibara/common";
7
+ import { defineCommand, runMain } from "citty";
8
+ import { availableIndexers, createIndexer } from "./internal/app";
9
+
10
+ type ProjectInfo = {
11
+ indexers: {
12
+ [indexerName: string]: {
13
+ [presetName: string]: {
14
+ type: string;
15
+ isFactory: boolean;
16
+ };
17
+ };
18
+ };
19
+ };
20
+
21
+ const startCommand = defineCommand({
22
+ meta: {
23
+ name: "write-project-info",
24
+ description: "Write json-encoded information about the project.",
25
+ },
26
+ args: {
27
+ "build-dir": {
28
+ type: "string",
29
+ description: "project build directory",
30
+ },
31
+ },
32
+ async run({ args }) {
33
+ const projectInfo: ProjectInfo = {
34
+ indexers: {},
35
+ };
36
+
37
+ // get all original runtime data from env
38
+ const { presets, runtimeConfig, userEnvRuntimeConfig } =
39
+ getRuntimeDataFromEnv();
40
+
41
+ for (const preset of Object.keys(presets ?? {})) {
42
+ // process runtime config for each preset
43
+ const processedRuntimeConfig = getProcessedRuntimeConfig({
44
+ preset,
45
+ presets,
46
+ runtimeConfig,
47
+ userEnvRuntimeConfig,
48
+ });
49
+ for (const indexer of availableIndexers) {
50
+ const { indexer: indexerInstance } =
51
+ (await createIndexer({
52
+ indexerName: indexer,
53
+ processedRuntimeConfig,
54
+ preset,
55
+ })) ?? {};
56
+ if (!indexerInstance) {
57
+ continue;
58
+ }
59
+ projectInfo.indexers[indexer] = {
60
+ ...(projectInfo.indexers[indexer] ?? {}),
61
+ [preset]: {
62
+ type: indexerInstance.streamConfig.name,
63
+ isFactory: indexerInstance.options.factory !== undefined,
64
+ },
65
+ };
66
+ }
67
+ }
68
+
69
+ const projectInfoPath = resolve(
70
+ args["build-dir"] ?? ".apibara",
71
+ "project-info.json",
72
+ );
73
+
74
+ writeFileSync(projectInfoPath, JSON.stringify(projectInfo, null, 2));
75
+ },
76
+ });
77
+
78
+ export const mainCli = defineCommand({
79
+ meta: {
80
+ name: "write-project-info-runner",
81
+ description: "Write json-encoded information about the project.",
82
+ },
83
+ subCommands: {
84
+ start: () => startCommand,
85
+ },
86
+ });
87
+
88
+ runMain(mainCli);
89
+
90
+ export default {};
@@ -1,6 +1,21 @@
1
- import { runWithReconnect } from "@apibara/indexer";
2
- import { createClient } from "@apibara/protocol";
1
+ import { ReloadIndexerRequest, runWithReconnect } from "@apibara/indexer";
2
+ import { createAuthenticatedClient } from "@apibara/protocol";
3
+ import {
4
+ checkForUnknownArgs,
5
+ getProcessedRuntimeConfig,
6
+ getRuntimeDataFromEnv,
7
+ } from "apibara/common";
3
8
  import { defineCommand, runMain } from "citty";
9
+ import consola, { type ConsolaInstance } from "consola";
10
+ import { blueBright } from "picocolors";
11
+ import { register } from "#apibara-internal-virtual/instrumentation";
12
+ // used when running with node .apibara/build/start.mjs as these values are made static during build time (except userEnvRuntimeConfig)
13
+ import {
14
+ preset as originalPreset,
15
+ presets,
16
+ runtimeConfig,
17
+ userEnvRuntimeConfig,
18
+ } from "#apibara-internal-virtual/static-config";
4
19
  import { createIndexer } from "./internal/app";
5
20
 
6
21
  const startCommand = defineCommand({
@@ -16,20 +31,85 @@ const startCommand = defineCommand({
16
31
  },
17
32
  preset: {
18
33
  type: "string",
19
- description: "Preset to use",
34
+ description: "Preset name",
35
+ },
36
+ standalone: {
37
+ type: "boolean",
38
+ default: true,
39
+ description:
40
+ "--standalone: can run the indexer just with node and without apibara cli \n\t\t\t --no-standalone: must run the indexer with apibara cli",
20
41
  },
21
42
  },
22
- async run({ args }) {
23
- const { indexer, preset } = args;
43
+ async run({ args, cmd }) {
44
+ const { indexer, preset: argPreset, standalone } = args;
45
+ await checkForUnknownArgs(args, cmd);
46
+
47
+ let _logger: ConsolaInstance | undefined;
48
+
49
+ while (true) {
50
+ try {
51
+ let preset: string | undefined;
52
+ let processedRuntimeConfig: Record<string, unknown> | undefined;
53
+
54
+ if (standalone) {
55
+ // when user does node .apibara/build/start.mjs
56
+ preset = argPreset ?? originalPreset;
57
+ processedRuntimeConfig = getProcessedRuntimeConfig({
58
+ preset,
59
+ presets,
60
+ runtimeConfig,
61
+ userEnvRuntimeConfig,
62
+ });
63
+ } else {
64
+ // When user does apibara start
65
+ const envResult = getRuntimeDataFromEnv();
66
+ preset = envResult.preset;
67
+ processedRuntimeConfig = envResult.processedRuntimeConfig;
68
+ }
69
+
70
+ const { indexer: indexerInstance, logger } =
71
+ (await createIndexer({
72
+ indexerName: indexer,
73
+ processedRuntimeConfig,
74
+ preset,
75
+ })) ?? {};
76
+
77
+ _logger = logger;
78
+
79
+ if (!indexerInstance) {
80
+ consola.error(
81
+ `Specified indexer "${indexer}" but it was not defined`,
82
+ );
83
+ process.exit(1);
84
+ }
85
+
86
+ const client = createAuthenticatedClient(
87
+ indexerInstance.streamConfig,
88
+ indexerInstance.options.streamUrl,
89
+ indexerInstance.options.clientOptions,
90
+ );
91
+
92
+ if (register) {
93
+ consola.start("Registering from instrumentation");
94
+ await register();
95
+ consola.success("Registered from instrumentation");
96
+ }
24
97
 
25
- const indexerInstance = createIndexer(indexer, preset);
98
+ if (logger) {
99
+ logger.info(`Indexer ${blueBright(indexer)} started`);
100
+ }
26
101
 
27
- const client = createClient(
28
- indexerInstance.streamConfig,
29
- indexerInstance.options.streamUrl,
30
- );
102
+ await runWithReconnect(client, indexerInstance);
31
103
 
32
- await runWithReconnect(client, indexerInstance);
104
+ return;
105
+ } catch (error) {
106
+ if (error instanceof ReloadIndexerRequest) {
107
+ _logger?.info(`Indexer ${blueBright(indexer)} reloaded`);
108
+ continue;
109
+ }
110
+ throw error;
111
+ }
112
+ }
33
113
  },
34
114
  });
35
115
 
@@ -1,21 +1,29 @@
1
1
  import type { ConsolaReporter } from "@apibara/indexer/plugins";
2
- import type { RollupCommonJSOptions } from "@rollup/plugin-commonjs";
3
2
  import type {
4
3
  C12InputConfig,
5
4
  ConfigWatcher,
6
5
  ResolvedConfig,
7
6
  WatchConfigOptions,
8
7
  } from "c12";
9
- import type { WatchOptions } from "chokidar";
10
8
  import type { NestedHooks } from "hookable";
9
+ import type { WatchOptions } from "rolldown";
10
+ import type { RolldownOptions } from "rolldown";
11
11
  import type { DeepPartial } from "./_utils";
12
12
  import type { ApibaraHooks } from "./hooks";
13
- import type { RollupConfig } from "./rollup";
14
13
 
15
- export type LoggerFactory = ({
14
+ export type RegisterFn = () => Promise<void>;
15
+
16
+ export type LoggerFactoryFn = ({
16
17
  indexer,
18
+ indexers,
17
19
  preset,
18
- }: { indexer: string; indexers: string[]; preset?: string }) => ConsolaReporter;
20
+ }: LoggerFactoryArgs) => ConsolaReporter;
21
+
22
+ export type LoggerFactoryArgs = {
23
+ indexer: string;
24
+ indexers: string[];
25
+ preset?: string;
26
+ };
19
27
 
20
28
  /**
21
29
  * Apibara Config type (apibara.config)
@@ -31,10 +39,12 @@ export interface ApibaraConfig<
31
39
  runtimeConfig?: R;
32
40
  presets?: T;
33
41
  preset?: keyof T;
34
- logger?: LoggerFactory;
35
42
  }
36
43
 
37
- export type ApibaraDynamicConfig = Pick<ApibaraConfig, "runtimeConfig">;
44
+ export type ApibaraDynamicConfig = Pick<
45
+ ApibaraConfig,
46
+ "runtimeConfig" | "preset" | "presets"
47
+ >;
38
48
 
39
49
  /**
40
50
  * Config loader options
@@ -68,22 +78,26 @@ export interface ApibaraOptions<
68
78
  buildDir: string;
69
79
  outputDir: string;
70
80
  indexersDir: string;
81
+ disableLogs?: boolean;
71
82
 
72
83
  // Dev
73
84
  dev: boolean;
74
- watchOptions: WatchOptions;
85
+ watchOptions: WatchOptions["watch"];
75
86
 
76
87
  // Hooks
77
88
  hooks: NestedHooks<ApibaraHooks>;
78
89
 
79
- // Logging
80
- logger?: LoggerFactory;
90
+ // Rolldown
91
+ rolldownConfig?: Partial<RolldownOptions>;
81
92
 
82
- // Rollup
83
- rollupConfig?: Partial<RollupConfig>;
93
+ /**
94
+ * @deprecated Use rolldownConfig instead. This option will be removed in future releases.
95
+ */
96
+ rollupConfig?: unknown;
84
97
  sourceMap?: boolean;
85
98
  entry: string;
86
- commonJS?: RollupCommonJSOptions;
99
+ node: boolean;
100
+ exportConditions?: string[];
87
101
 
88
102
  // Advanced
89
103
  typescript: {
@@ -1,12 +1,15 @@
1
+ import type { RolldownOptions } from "rolldown";
1
2
  import type { Apibara } from "./apibara";
2
- import type { RollupConfig } from "./rollup";
3
3
 
4
4
  export interface ApibaraHooks {
5
- "rollup:before": (apibara: Apibara, rollupConfig: RollupConfig) => void;
5
+ "rolldown:before": (
6
+ apibara: Apibara,
7
+ rolldownConfig: RolldownOptions,
8
+ ) => void;
6
9
  compiled: (apibara: Apibara) => void;
7
- "dev:restart": () => void;
8
- "dev:reload": () => void;
9
- "rollup:reload": () => void;
10
+ "dev:restart": () => Promise<void>;
11
+ "dev:reload": () => Promise<void>;
12
+ "rolldown:reload": () => Promise<void>;
10
13
  restart: () => void;
11
14
  close: () => void;
12
15
  }
@@ -2,5 +2,5 @@ export * from "./apibara";
2
2
  export * from "./_utils";
3
3
  export * from "./config";
4
4
  export * from "./hooks";
5
- export * from "./rollup";
5
+ export * from "./rolldown";
6
6
  export * from "./runtime";
@@ -0,0 +1,5 @@
1
+ import type { InputOptions, OutputOptions } from "rolldown";
2
+
3
+ export type RolldownConfig = InputOptions & {
4
+ output: OutputOptions;
5
+ };
@@ -7,4 +7,7 @@ export type IndexerConstructor =
7
7
  ) => IndexerWithStreamConfig<unknown, unknown, unknown>)
8
8
  | IndexerWithStreamConfig<unknown, unknown, unknown>;
9
9
 
10
- export const indexers: { name: string; indexer: IndexerConstructor }[] = [];
10
+ export const indexers: {
11
+ name: string;
12
+ indexer: { default?: IndexerConstructor | undefined };
13
+ }[] = [];
@@ -0,0 +1,4 @@
1
+ import type { LoggerFactoryFn, RegisterFn } from "apibara/types";
2
+
3
+ export const register: RegisterFn | undefined = undefined;
4
+ export const logger: LoggerFactoryFn | undefined = undefined;
@@ -0,0 +1,4 @@
1
+ export const preset: string | undefined = undefined;
2
+ export const presets: Record<string, unknown> = {};
3
+ export const runtimeConfig: Record<string, unknown> = {};
4
+ export const userEnvRuntimeConfig: Record<string, unknown> = {};
@@ -1,6 +0,0 @@
1
- import { Apibara, RollupConfig } from 'apibara/types';
2
- export { Plugin } from 'rollup';
3
-
4
- declare function getRollupConfig(apibara: Apibara): RollupConfig;
5
-
6
- export { getRollupConfig };
@@ -1,6 +0,0 @@
1
- import { Apibara, RollupConfig } from 'apibara/types';
2
- export { Plugin } from 'rollup';
3
-
4
- declare function getRollupConfig(apibara: Apibara): RollupConfig;
5
-
6
- export { getRollupConfig };