apibara 2.1.0-beta.3 → 2.1.0-beta.30

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 (81) hide show
  1. package/dist/chunks/add.mjs +16 -8
  2. package/dist/chunks/build.mjs +4 -2
  3. package/dist/chunks/dev.mjs +44 -14
  4. package/dist/chunks/init.mjs +11 -7
  5. package/dist/chunks/prepare.mjs +4 -2
  6. package/dist/chunks/start.mjs +14 -4
  7. package/dist/chunks/write-project-info.mjs +50 -0
  8. package/dist/cli/index.mjs +2 -1
  9. package/dist/core/index.mjs +98 -68
  10. package/dist/create/index.d.mts +2 -1
  11. package/dist/create/index.d.ts +2 -1
  12. package/dist/create/index.mjs +142 -112
  13. package/dist/hooks/index.mjs +1 -1
  14. package/dist/rolldown/index.d.mts +7 -0
  15. package/dist/rolldown/index.d.ts +7 -0
  16. package/dist/rolldown/index.mjs +159 -0
  17. package/dist/runtime/dev.mjs +14 -4
  18. package/dist/runtime/internal/app.d.ts +6 -1
  19. package/dist/runtime/internal/app.mjs +50 -19
  20. package/dist/runtime/internal/helper.d.ts +12 -0
  21. package/dist/runtime/internal/helper.mjs +33 -0
  22. package/dist/runtime/project-info.d.ts +3 -0
  23. package/dist/runtime/project-info.mjs +53 -0
  24. package/dist/runtime/start.mjs +18 -4
  25. package/dist/shared/apibara.63c9a277.mjs +29 -0
  26. package/dist/shared/apibara.730bb1e4.mjs +17 -0
  27. package/dist/types/index.d.mts +23 -19
  28. package/dist/types/index.d.ts +23 -19
  29. package/package.json +13 -16
  30. package/src/cli/commands/add.ts +16 -7
  31. package/src/cli/commands/build.ts +5 -2
  32. package/src/cli/commands/dev.ts +56 -13
  33. package/src/cli/commands/init.ts +12 -7
  34. package/src/cli/commands/prepare.ts +4 -2
  35. package/src/cli/commands/start.ts +16 -3
  36. package/src/cli/commands/write-project-info.ts +56 -0
  37. package/src/cli/common.ts +33 -1
  38. package/src/cli/index.ts +2 -0
  39. package/src/core/apibara.ts +5 -0
  40. package/src/core/build/build.ts +13 -5
  41. package/src/core/build/dev.ts +44 -23
  42. package/src/core/build/error.ts +9 -14
  43. package/src/core/build/prepare.ts +5 -3
  44. package/src/core/build/prod.ts +25 -16
  45. package/src/core/build/types.ts +11 -1
  46. package/src/core/config/defaults.ts +3 -0
  47. package/src/core/config/loader.ts +13 -7
  48. package/src/core/config/resolvers/preset.resolver.ts +3 -0
  49. package/src/core/config/update.ts +1 -1
  50. package/src/create/add.ts +10 -9
  51. package/src/create/constants.ts +10 -11
  52. package/src/create/init.ts +8 -5
  53. package/src/create/templates.ts +130 -102
  54. package/src/hooks/useRuntimeConfig.ts +1 -1
  55. package/src/rolldown/config.ts +111 -0
  56. package/src/rolldown/index.ts +2 -0
  57. package/src/rolldown/plugins/config.ts +17 -0
  58. package/src/{rollup → rolldown}/plugins/indexers.ts +3 -3
  59. package/src/rolldown/plugins/instrumentation.ts +68 -0
  60. package/src/runtime/dev.ts +16 -4
  61. package/src/runtime/internal/app.ts +66 -25
  62. package/src/runtime/internal/helper.ts +55 -0
  63. package/src/runtime/project-info.ts +72 -0
  64. package/src/runtime/start.ts +21 -4
  65. package/src/types/config.ts +23 -12
  66. package/src/types/hooks.ts +8 -5
  67. package/src/types/index.ts +1 -1
  68. package/src/types/rolldown.ts +5 -0
  69. package/src/types/virtual/config.d.ts +4 -1
  70. package/src/types/virtual/indexers.d.ts +4 -1
  71. package/src/types/virtual/instrumentation.d.ts +4 -0
  72. package/dist/rollup/index.d.mts +0 -6
  73. package/dist/rollup/index.d.ts +0 -6
  74. package/dist/rollup/index.mjs +0 -150
  75. package/dist/shared/apibara.1b515d04.mjs +0 -8
  76. package/src/core/config/resolvers/runtime-config.resolver.ts +0 -6
  77. package/src/rollup/config.ts +0 -87
  78. package/src/rollup/index.ts +0 -2
  79. package/src/rollup/plugins/config.ts +0 -12
  80. package/src/rollup/plugins/esm-shim.ts +0 -69
  81. package/src/types/rollup.ts +0 -8
@@ -0,0 +1,17 @@
1
+ import virtual from "@rollup/plugin-virtual";
2
+ import type { Apibara } from "apibara/types";
3
+ import type { RolldownPluginOption } from "rolldown";
4
+
5
+ export function appConfig(apibara: Apibara) {
6
+ return virtual({
7
+ "#apibara-internal-virtual/config": `
8
+ const serializedConfig = \`process.env.APIBARA_CONFIG\`;
9
+
10
+ if (serializedConfig === undefined || serializedConfig === "") {
11
+ throw new Error("APIBARA_CONFIG is not defined");
12
+ }
13
+
14
+ export const config = JSON.parse(serializedConfig);
15
+ `,
16
+ }) as RolldownPluginOption;
17
+ }
@@ -1,17 +1,17 @@
1
1
  import virtual from "@rollup/plugin-virtual";
2
2
  import type { Apibara } from "apibara/types";
3
3
  import { hash } from "ohash";
4
+ import type { RolldownPluginOption } from "rolldown";
4
5
 
5
6
  export function indexers(apibara: Apibara) {
6
7
  const indexers = [...new Set(apibara.indexers)];
7
-
8
8
  return virtual({
9
9
  "#apibara-internal-virtual/indexers": `
10
- ${indexers.map((i) => `import _${hash(i)} from '${i.indexer}';`).join("\n")}
10
+ ${indexers.map((i) => `import * as _${hash(i)} from '${i.indexer}';`).join("\n")}
11
11
 
12
12
  export const indexers = [
13
13
  ${indexers.map((i) => `{ name: "${i.name}", indexer: _${hash(i)} }`).join(",\n")}
14
14
  ];
15
15
  `,
16
- });
16
+ }) as RolldownPluginOption;
17
17
  }
@@ -0,0 +1,68 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import virtual from "@rollup/plugin-virtual";
4
+ import type { Apibara } from "apibara/types";
5
+ import type { RolldownPluginOption } from "rolldown";
6
+
7
+ export function instrumentation(apibara: Apibara) {
8
+ const instrumentationPath = join(
9
+ apibara.options._c12.cwd!,
10
+ `instrumentation.${apibara.options._c12.configFile?.endsWith(".ts") ? "ts" : "js"}`,
11
+ );
12
+
13
+ if (!existsSync(instrumentationPath)) {
14
+ return virtual({
15
+ "#apibara-internal-virtual/instrumentation": `
16
+ let register = undefined;
17
+ let logger = undefined;
18
+
19
+ export { register, logger };
20
+ `,
21
+ }) as RolldownPluginOption;
22
+ }
23
+
24
+ /**
25
+ * We are importing the instrumentation file inline with "require" instead of "import" at the top of the file to avoid warnings from rolldown
26
+ * when some methods are not defined in the instrumentation file.
27
+ *
28
+ * Example warning:
29
+ *
30
+ * [IMPORT_IS_UNDEFINED] Warning: Import `logger` will always be undefined because there is no matching export in 'instrumentation.ts'
31
+ * ╭─[virtual:#apibara-internal-virtual/instrumentation:11:35]
32
+ * │
33
+ * 11 │ if (instrumentation && typeof instrumentation.logger === "function") {
34
+ * │ ───────────┬──────────
35
+ * │ ╰────────────
36
+ * ────╯
37
+
38
+ * [IMPORT_IS_UNDEFINED] Warning: Import `logger` will always be undefined because there is no matching export in 'instrumentation.ts'
39
+ * ╭─[virtual:#apibara-internal-virtual/instrumentation:12:16]
40
+ * │
41
+ * 12 │ logger = instrumentation.logger;
42
+ * │ ───────────┬──────────
43
+ * │ ╰────────────
44
+ * ────╯
45
+ */
46
+ return virtual({
47
+ "#apibara-internal-virtual/instrumentation": `
48
+ let register = undefined;
49
+ let logger = undefined;
50
+
51
+ try {
52
+ const instrumentation = require('${instrumentationPath}');
53
+
54
+ if (instrumentation?.register && typeof instrumentation.register === "function") {
55
+ register = instrumentation.register;
56
+ }
57
+
58
+ if (instrumentation?.logger && typeof instrumentation.logger === "function") {
59
+ logger = instrumentation.logger;
60
+ }
61
+ } catch {
62
+ // Silently handle any require errors
63
+ }
64
+
65
+ export { register, logger };
66
+ `,
67
+ }) as RolldownPluginOption;
68
+ }
@@ -1,7 +1,11 @@
1
1
  import { runWithReconnect } from "@apibara/indexer";
2
- import { createClient } from "@apibara/protocol";
3
2
  import { defineCommand, runMain } from "citty";
4
- import { availableIndexers, createIndexer } from "./internal/app";
3
+ import { blueBright } from "picocolors";
4
+ import {
5
+ availableIndexers,
6
+ createAuthenticatedClient,
7
+ createIndexer,
8
+ } from "./internal/app";
5
9
 
6
10
  const startCommand = defineCommand({
7
11
  meta: {
@@ -36,13 +40,21 @@ const startCommand = defineCommand({
36
40
 
37
41
  await Promise.all(
38
42
  selectedIndexers.map(async (indexer) => {
39
- const indexerInstance = createIndexer(indexer, preset);
43
+ const { indexer: indexerInstance, logger } =
44
+ createIndexer(indexer, preset) ?? {};
45
+ if (!indexerInstance) {
46
+ return;
47
+ }
40
48
 
41
- const client = createClient(
49
+ const client = createAuthenticatedClient(
42
50
  indexerInstance.streamConfig,
43
51
  indexerInstance.options.streamUrl,
44
52
  );
45
53
 
54
+ if (logger) {
55
+ logger.info(`Indexer ${blueBright(indexer)} started`);
56
+ }
57
+
46
58
  await runWithReconnect(client, indexerInstance);
47
59
  }),
48
60
  );
@@ -8,31 +8,31 @@ import {
8
8
  inMemoryPersistence,
9
9
  logger,
10
10
  } from "@apibara/indexer/plugins";
11
+ import {
12
+ type CreateClientOptions,
13
+ Metadata,
14
+ type StreamConfig,
15
+ createClient,
16
+ } from "@apibara/protocol";
17
+ import consola from "consola";
11
18
  import { config } from "#apibara-internal-virtual/config";
12
19
  import { indexers } from "#apibara-internal-virtual/indexers";
20
+ import { logger as instrumentationLogger } from "#apibara-internal-virtual/instrumentation";
21
+ import { getProcessedRuntimeConfig } from "./helper";
13
22
  import { createLogger } from "./logger";
14
23
 
15
24
  export const availableIndexers = indexers.map((i) => i.name);
16
25
 
17
26
  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
- }
27
+ // Get merged runtime config from preset and process.env.APIBARA_RUNTIME_CONFIG and defaults.
28
+ const runtimeConfig = getProcessedRuntimeConfig({
29
+ preset,
30
+ presets: config.presets,
31
+ runtimeConfig: config.runtimeConfig,
32
+ });
30
33
 
31
- const presetValue = config.presets[preset] as {
32
- runtimeConfig: Record<string, unknown>;
33
- };
34
- runtimeConfig = { ...runtimeConfig, ...presetValue.runtimeConfig };
35
- }
34
+ // Set the runtime config in the environment so that it can be used by the useRuntimeConfig hook.
35
+ process.env.APIBARA_RUNTIME_CONFIG_HOOK_DATA = JSON.stringify(runtimeConfig);
36
36
 
37
37
  const indexerDefinition = indexers.find((i) => i.name === indexerName);
38
38
 
@@ -42,10 +42,18 @@ export function createIndexer(indexerName: string, preset?: string) {
42
42
  );
43
43
  }
44
44
 
45
+ const indexerModule = indexerDefinition.indexer?.default;
46
+ if (indexerModule === undefined) {
47
+ consola.warn(
48
+ `Specified indexer "${indexerName}" but it does not export a default. Ignoring.`,
49
+ );
50
+ return;
51
+ }
52
+
45
53
  const definition =
46
- typeof indexerDefinition.indexer === "function"
47
- ? indexerDefinition.indexer(runtimeConfig)
48
- : indexerDefinition.indexer;
54
+ typeof indexerModule === "function"
55
+ ? indexerModule(runtimeConfig)
56
+ : indexerModule;
49
57
 
50
58
  let reporter: ConsolaReporter = createLogger({
51
59
  indexer: indexerName,
@@ -53,26 +61,59 @@ export function createIndexer(indexerName: string, preset?: string) {
53
61
  indexers: availableIndexers,
54
62
  });
55
63
 
56
- if (config.logger) {
57
- reporter = config.logger({
64
+ // Check if a custom logger is provided through instrumentation
65
+ if (instrumentationLogger) {
66
+ // Create a reporter using the custom logger function
67
+ const _reporter = instrumentationLogger({
58
68
  indexer: indexerName,
59
69
  preset,
60
70
  indexers: availableIndexers,
61
71
  });
72
+
73
+ // If the reporter is valid (has a log method), use it instead of the default
74
+ if (_reporter && "log" in _reporter) {
75
+ reporter = _reporter;
76
+ }
62
77
  }
63
78
 
64
79
  // Put the in-memory persistence plugin first so that it can be overridden by any user-defined
65
80
  // persistence plugin.
66
- // Put the logger last since we want to override any user-defined logger.
67
81
  definition.plugins = [
68
82
  internalContext({
69
83
  indexerName,
70
84
  availableIndexers,
71
85
  } as InternalContext),
86
+ logger({ logger: reporter }),
72
87
  inMemoryPersistence(),
73
88
  ...(definition.plugins ?? []),
74
- logger({ logger: reporter }),
75
89
  ];
76
90
 
77
- return _createIndexer(definition);
91
+ return {
92
+ indexer: _createIndexer(definition),
93
+ logger: consola.create({ reporters: [reporter] }),
94
+ };
95
+ }
96
+
97
+ export function createAuthenticatedClient(
98
+ config: StreamConfig<unknown, unknown>,
99
+ streamUrl: string,
100
+ options?: CreateClientOptions,
101
+ ) {
102
+ const dnaToken = process.env.DNA_TOKEN;
103
+ if (!dnaToken) {
104
+ consola.warn(
105
+ "DNA_TOKEN environment variable is not set. Trying to connect without authentication.",
106
+ );
107
+ }
108
+
109
+ return createClient(config, streamUrl, {
110
+ ...options,
111
+ defaultCallOptions: {
112
+ "*": {
113
+ metadata: Metadata({
114
+ Authorization: `Bearer ${dnaToken}`,
115
+ }),
116
+ },
117
+ },
118
+ });
78
119
  }
@@ -0,0 +1,55 @@
1
+ import defu from "defu";
2
+
3
+ /**
4
+ * Get the merged runtime config from the process.env.APIBARA_RUNTIME_CONFIG, presets and defaults.
5
+ * Priority (Highest to lowest):
6
+ * 1. process.env.APIBARA_RUNTIME_CONFIG
7
+ * 2. Preset
8
+ * 3. Defaults
9
+ */
10
+ export function getProcessedRuntimeConfig({
11
+ preset,
12
+ presets,
13
+ runtimeConfig,
14
+ }: {
15
+ preset?: string;
16
+ presets?: Record<string, unknown>;
17
+ runtimeConfig?: Record<string, unknown>;
18
+ }) {
19
+ let _runtimeConfig: Record<string, unknown> = { ...runtimeConfig };
20
+ const envRuntimeConfig = process.env.APIBARA_RUNTIME_CONFIG;
21
+
22
+ if (preset) {
23
+ if (presets === undefined) {
24
+ throw new Error(
25
+ `Specified preset "${preset}" but no presets were defined`,
26
+ );
27
+ }
28
+
29
+ if (presets[preset] === undefined) {
30
+ throw new Error(`Specified preset "${preset}" but it was not defined`);
31
+ }
32
+
33
+ const presetValue = presets[preset] as {
34
+ runtimeConfig: Record<string, unknown>;
35
+ };
36
+
37
+ // Preset applied
38
+ _runtimeConfig = defu(presetValue.runtimeConfig, _runtimeConfig);
39
+ }
40
+
41
+ if (envRuntimeConfig) {
42
+ try {
43
+ // Environment runtime config applied
44
+ const envRuntimeConfigValue = JSON.parse(envRuntimeConfig);
45
+ _runtimeConfig = defu(envRuntimeConfigValue, _runtimeConfig);
46
+ } catch (error) {
47
+ throw new Error(
48
+ "Failed to parse runtime config from process.env.APIBARA_RUNTIME_CONFIG. Please ensure it is a valid JSON string.",
49
+ { cause: error },
50
+ );
51
+ }
52
+ }
53
+
54
+ return _runtimeConfig;
55
+ }
@@ -0,0 +1,72 @@
1
+ import { writeFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import { defineCommand, runMain } from "citty";
4
+ import { config } from "#apibara-internal-virtual/config";
5
+ import { availableIndexers, createIndexer } from "./internal/app";
6
+
7
+ type ProjectInfo = {
8
+ indexers: {
9
+ [indexerName: string]: {
10
+ [presetName: string]: {
11
+ type: string;
12
+ isFactory: boolean;
13
+ };
14
+ };
15
+ };
16
+ };
17
+
18
+ const startCommand = defineCommand({
19
+ meta: {
20
+ name: "write-project-info",
21
+ description: "Write json-encoded information about the project.",
22
+ },
23
+ args: {
24
+ "build-dir": {
25
+ type: "string",
26
+ description: "project build directory",
27
+ },
28
+ },
29
+ async run({ args }) {
30
+ const projectInfo: ProjectInfo = {
31
+ indexers: {},
32
+ };
33
+
34
+ for (const preset of Object.keys(config.presets ?? {})) {
35
+ for (const indexer of availableIndexers) {
36
+ const { indexer: indexerInstance } =
37
+ createIndexer(indexer, preset) ?? {};
38
+ if (!indexerInstance) {
39
+ continue;
40
+ }
41
+ projectInfo.indexers[indexer] = {
42
+ ...(projectInfo.indexers[indexer] ?? {}),
43
+ [preset]: {
44
+ type: indexerInstance.streamConfig.name,
45
+ isFactory: indexerInstance.options.factory !== undefined,
46
+ },
47
+ };
48
+ }
49
+ }
50
+
51
+ const projectInfoPath = resolve(
52
+ args["build-dir"] ?? ".apibara",
53
+ "project-info.json",
54
+ );
55
+
56
+ writeFileSync(projectInfoPath, JSON.stringify(projectInfo, null, 2));
57
+ },
58
+ });
59
+
60
+ export const mainCli = defineCommand({
61
+ meta: {
62
+ name: "write-project-info-runner",
63
+ description: "Write json-encoded information about the project.",
64
+ },
65
+ subCommands: {
66
+ start: () => startCommand,
67
+ },
68
+ });
69
+
70
+ runMain(mainCli);
71
+
72
+ export default {};
@@ -1,7 +1,9 @@
1
1
  import { runWithReconnect } from "@apibara/indexer";
2
- import { createClient } from "@apibara/protocol";
3
2
  import { defineCommand, runMain } from "citty";
4
- import { createIndexer } from "./internal/app";
3
+ import consola from "consola";
4
+ import { blueBright } from "picocolors";
5
+ import { register } from "#apibara-internal-virtual/instrumentation";
6
+ import { createAuthenticatedClient, createIndexer } from "./internal/app";
5
7
 
6
8
  const startCommand = defineCommand({
7
9
  meta: {
@@ -22,13 +24,28 @@ const startCommand = defineCommand({
22
24
  async run({ args }) {
23
25
  const { indexer, preset } = args;
24
26
 
25
- const indexerInstance = createIndexer(indexer, preset);
27
+ const { indexer: indexerInstance, logger } =
28
+ createIndexer(indexer, preset) ?? {};
29
+ if (!indexerInstance) {
30
+ consola.error(`Specified indexer "${indexer}" but it was not defined`);
31
+ process.exit(1);
32
+ }
26
33
 
27
- const client = createClient(
34
+ const client = createAuthenticatedClient(
28
35
  indexerInstance.streamConfig,
29
36
  indexerInstance.options.streamUrl,
30
37
  );
31
38
 
39
+ if (register) {
40
+ consola.start("Registering from instrumentation");
41
+ await register();
42
+ consola.success("Registered from instrumentation");
43
+ }
44
+
45
+ if (logger) {
46
+ logger.info(`Indexer ${blueBright(indexer)} started`);
47
+ }
48
+
32
49
  await runWithReconnect(client, indexerInstance);
33
50
  },
34
51
  });
@@ -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,7 +39,6 @@ export interface ApibaraConfig<
31
39
  runtimeConfig?: R;
32
40
  presets?: T;
33
41
  preset?: keyof T;
34
- logger?: LoggerFactory;
35
42
  }
36
43
 
37
44
  export type ApibaraDynamicConfig = Pick<ApibaraConfig, "runtimeConfig">;
@@ -68,22 +75,26 @@ export interface ApibaraOptions<
68
75
  buildDir: string;
69
76
  outputDir: string;
70
77
  indexersDir: string;
78
+ disableLogs?: boolean;
71
79
 
72
80
  // Dev
73
81
  dev: boolean;
74
- watchOptions: WatchOptions;
82
+ watchOptions: WatchOptions["watch"];
75
83
 
76
84
  // Hooks
77
85
  hooks: NestedHooks<ApibaraHooks>;
78
86
 
79
- // Logging
80
- logger?: LoggerFactory;
87
+ // Rolldown
88
+ rolldownConfig?: Partial<RolldownOptions>;
81
89
 
82
- // Rollup
83
- rollupConfig?: Partial<RollupConfig>;
90
+ /**
91
+ * @deprecated Use rolldownConfig instead. This option will be removed in future releases.
92
+ */
93
+ rollupConfig?: unknown;
84
94
  sourceMap?: boolean;
85
95
  entry: string;
86
- commonJS?: RollupCommonJSOptions;
96
+ node: boolean;
97
+ exportConditions?: string[];
87
98
 
88
99
  // Advanced
89
100
  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
+ };
@@ -1,3 +1,6 @@
1
1
  import type { ApibaraConfig } from "apibara/types";
2
2
 
3
- export const config: ApibaraConfig = {};
3
+ export const config: Pick<
4
+ ApibaraConfig,
5
+ "runtimeConfig" | "preset" | "presets"
6
+ > = {};
@@ -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;
@@ -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 };