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,67 @@
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.mjs";
9
+ const startCommand = defineCommand({
10
+ meta: {
11
+ name: "write-project-info",
12
+ description: "Write json-encoded information about the project."
13
+ },
14
+ args: {
15
+ "build-dir": {
16
+ type: "string",
17
+ description: "project build directory"
18
+ }
19
+ },
20
+ async run({ args }) {
21
+ const projectInfo = {
22
+ indexers: {}
23
+ };
24
+ const { presets, runtimeConfig, userEnvRuntimeConfig } = getRuntimeDataFromEnv();
25
+ for (const preset of Object.keys(presets ?? {})) {
26
+ const processedRuntimeConfig = getProcessedRuntimeConfig({
27
+ preset,
28
+ presets,
29
+ runtimeConfig,
30
+ userEnvRuntimeConfig
31
+ });
32
+ for (const indexer of availableIndexers) {
33
+ const { indexer: indexerInstance } = await createIndexer({
34
+ indexerName: indexer,
35
+ processedRuntimeConfig,
36
+ preset
37
+ }) ?? {};
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 !== void 0
46
+ }
47
+ };
48
+ }
49
+ }
50
+ const projectInfoPath = resolve(
51
+ args["build-dir"] ?? ".apibara",
52
+ "project-info.json"
53
+ );
54
+ writeFileSync(projectInfoPath, JSON.stringify(projectInfo, null, 2));
55
+ }
56
+ });
57
+ export const mainCli = defineCommand({
58
+ meta: {
59
+ name: "write-project-info-runner",
60
+ description: "Write json-encoded information about the project."
61
+ },
62
+ subCommands: {
63
+ start: () => startCommand
64
+ }
65
+ });
66
+ runMain(mainCli);
67
+ export default {};
@@ -1,6 +1,20 @@
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 from "consola";
10
+ import { blueBright } from "picocolors";
11
+ import { register } from "#apibara-internal-virtual/instrumentation";
12
+ import {
13
+ preset as originalPreset,
14
+ presets,
15
+ runtimeConfig,
16
+ userEnvRuntimeConfig
17
+ } from "#apibara-internal-virtual/static-config";
4
18
  import { createIndexer } from "./internal/app.mjs";
5
19
  const startCommand = defineCommand({
6
20
  meta: {
@@ -15,17 +29,70 @@ const startCommand = defineCommand({
15
29
  },
16
30
  preset: {
17
31
  type: "string",
18
- description: "Preset to use"
32
+ description: "Preset name"
33
+ },
34
+ standalone: {
35
+ type: "boolean",
36
+ default: true,
37
+ description: "--standalone: can run the indexer just with node and without apibara cli \n --no-standalone: must run the indexer with apibara cli"
19
38
  }
20
39
  },
21
- async run({ args }) {
22
- const { indexer, preset } = args;
23
- const indexerInstance = createIndexer(indexer, preset);
24
- const client = createClient(
25
- indexerInstance.streamConfig,
26
- indexerInstance.options.streamUrl
27
- );
28
- await runWithReconnect(client, indexerInstance);
40
+ async run({ args, cmd }) {
41
+ const { indexer, preset: argPreset, standalone } = args;
42
+ await checkForUnknownArgs(args, cmd);
43
+ let _logger;
44
+ while (true) {
45
+ try {
46
+ let preset;
47
+ let processedRuntimeConfig;
48
+ if (standalone) {
49
+ preset = argPreset ?? originalPreset;
50
+ processedRuntimeConfig = getProcessedRuntimeConfig({
51
+ preset,
52
+ presets,
53
+ runtimeConfig,
54
+ userEnvRuntimeConfig
55
+ });
56
+ } else {
57
+ const envResult = getRuntimeDataFromEnv();
58
+ preset = envResult.preset;
59
+ processedRuntimeConfig = envResult.processedRuntimeConfig;
60
+ }
61
+ const { indexer: indexerInstance, logger } = await createIndexer({
62
+ indexerName: indexer,
63
+ processedRuntimeConfig,
64
+ preset
65
+ }) ?? {};
66
+ _logger = logger;
67
+ if (!indexerInstance) {
68
+ consola.error(
69
+ `Specified indexer "${indexer}" but it was not defined`
70
+ );
71
+ process.exit(1);
72
+ }
73
+ const client = createAuthenticatedClient(
74
+ indexerInstance.streamConfig,
75
+ indexerInstance.options.streamUrl,
76
+ indexerInstance.options.clientOptions
77
+ );
78
+ if (register) {
79
+ consola.start("Registering from instrumentation");
80
+ await register();
81
+ consola.success("Registered from instrumentation");
82
+ }
83
+ if (logger) {
84
+ logger.info(`Indexer ${blueBright(indexer)} started`);
85
+ }
86
+ await runWithReconnect(client, indexerInstance);
87
+ return;
88
+ } catch (error) {
89
+ if (error instanceof ReloadIndexerRequest) {
90
+ _logger?.info(`Indexer ${blueBright(indexer)} reloaded`);
91
+ continue;
92
+ }
93
+ throw error;
94
+ }
95
+ }
29
96
  }
30
97
  });
31
98
  export const mainCli = defineCommand({
@@ -0,0 +1,18 @@
1
+ import colors from 'picocolors';
2
+
3
+ const {
4
+ blue,
5
+ blueBright,
6
+ cyan,
7
+ gray,
8
+ green,
9
+ greenBright,
10
+ magenta,
11
+ red,
12
+ redBright,
13
+ reset,
14
+ yellow
15
+ } = colors;
16
+
17
+ export { blue as a, blueBright as b, green as c, cyan as d, reset as e, gray as g, magenta as m, red as r, yellow as y };
18
+ //# sourceMappingURL=apibara.730bb1e4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apibara.730bb1e4.mjs","sources":["../../src/create/colors.ts"],"sourcesContent":["import colors from \"picocolors\";\n\nexport const {\n blue,\n blueBright,\n cyan,\n gray,\n green,\n greenBright,\n magenta,\n red,\n redBright,\n reset,\n yellow,\n} = colors;\n"],"names":[],"mappings":";;AAEa,MAAA;AAAA,EACX,IAAA;AAAA,EACA,UAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA;AAAA,EACA,GAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AACF,CAAI,GAAA;;;;"}
@@ -1,34 +1,30 @@
1
1
  import { ConsolaInstance } from 'consola';
2
2
  import { NestedHooks, Hookable } from 'hookable';
3
3
  import { ConsolaReporter } from '@apibara/indexer/plugins';
4
- import { RollupCommonJSOptions } from '@rollup/plugin-commonjs';
5
4
  import { C12InputConfig, WatchConfigOptions, ResolvedConfig, ConfigWatcher } from 'c12';
6
- import { WatchOptions } from 'chokidar';
7
- import { InputOptions, OutputOptions } from 'rollup';
5
+ import { RolldownOptions, WatchOptions, InputOptions, OutputOptions } from 'rolldown';
8
6
 
9
7
  type DeepPartial<T> = T extends Record<string, any> ? {
10
8
  [P in keyof T]?: DeepPartial<T[P]> | T[P];
11
9
  } : T;
12
10
 
13
- type RollupConfig = InputOptions & {
14
- output: OutputOptions;
15
- };
16
-
17
11
  interface ApibaraHooks {
18
- "rollup:before": (apibara: Apibara, rollupConfig: RollupConfig) => void;
12
+ "rolldown:before": (apibara: Apibara, rolldownConfig: RolldownOptions) => void;
19
13
  compiled: (apibara: Apibara) => void;
20
- "dev:restart": () => void;
21
- "dev:reload": () => void;
22
- "rollup:reload": () => void;
14
+ "dev:restart": () => Promise<void>;
15
+ "dev:reload": () => Promise<void>;
16
+ "rolldown:reload": () => Promise<void>;
23
17
  restart: () => void;
24
18
  close: () => void;
25
19
  }
26
20
 
27
- type LoggerFactory = ({ indexer, preset, }: {
21
+ type RegisterFn = () => Promise<void>;
22
+ type LoggerFactoryFn = ({ indexer, indexers, preset, }: LoggerFactoryArgs) => ConsolaReporter;
23
+ type LoggerFactoryArgs = {
28
24
  indexer: string;
29
25
  indexers: string[];
30
26
  preset?: string;
31
- }) => ConsolaReporter;
27
+ };
32
28
  /**
33
29
  * Apibara Config type (apibara.config)
34
30
  */
@@ -36,9 +32,8 @@ interface ApibaraConfig<T extends Record<string, DeepPartial<Pick<ApibaraConfig<
36
32
  runtimeConfig?: R;
37
33
  presets?: T;
38
34
  preset?: keyof T;
39
- logger?: LoggerFactory;
40
35
  }
41
- type ApibaraDynamicConfig = Pick<ApibaraConfig, "runtimeConfig">;
36
+ type ApibaraDynamicConfig = Pick<ApibaraConfig, "runtimeConfig" | "preset" | "presets">;
42
37
  /**
43
38
  * Config loader options
44
39
  */
@@ -57,14 +52,19 @@ interface ApibaraOptions<T extends Record<string, DeepPartial<Pick<ApibaraConfig
57
52
  buildDir: string;
58
53
  outputDir: string;
59
54
  indexersDir: string;
55
+ disableLogs?: boolean;
60
56
  dev: boolean;
61
- watchOptions: WatchOptions;
57
+ watchOptions: WatchOptions["watch"];
62
58
  hooks: NestedHooks<ApibaraHooks>;
63
- logger?: LoggerFactory;
64
- rollupConfig?: Partial<RollupConfig>;
59
+ rolldownConfig?: Partial<RolldownOptions>;
60
+ /**
61
+ * @deprecated Use rolldownConfig instead. This option will be removed in future releases.
62
+ */
63
+ rollupConfig?: unknown;
65
64
  sourceMap?: boolean;
66
65
  entry: string;
67
- commonJS?: RollupCommonJSOptions;
66
+ node: boolean;
67
+ exportConditions?: string[];
68
68
  typescript: {
69
69
  strict?: boolean;
70
70
  internalPaths?: boolean;
@@ -85,6 +85,10 @@ interface Apibara {
85
85
  updateConfig: (config: ApibaraDynamicConfig) => void | Promise<void>;
86
86
  }
87
87
 
88
+ type RolldownConfig = InputOptions & {
89
+ output: OutputOptions;
90
+ };
91
+
88
92
  type ApibaraRuntimeConfig = Record<string, unknown>;
89
93
 
90
- export type { Apibara, ApibaraConfig, ApibaraDynamicConfig, ApibaraHooks, ApibaraOptions, ApibaraRuntimeConfig, DeepPartial, IndexerDefinition, LoadConfigOptions, LoggerFactory, RollupConfig };
94
+ export type { Apibara, ApibaraConfig, ApibaraDynamicConfig, ApibaraHooks, ApibaraOptions, ApibaraRuntimeConfig, DeepPartial, IndexerDefinition, LoadConfigOptions, LoggerFactoryArgs, LoggerFactoryFn, RegisterFn, RolldownConfig };
@@ -1,34 +1,30 @@
1
1
  import { ConsolaInstance } from 'consola';
2
2
  import { NestedHooks, Hookable } from 'hookable';
3
3
  import { ConsolaReporter } from '@apibara/indexer/plugins';
4
- import { RollupCommonJSOptions } from '@rollup/plugin-commonjs';
5
4
  import { C12InputConfig, WatchConfigOptions, ResolvedConfig, ConfigWatcher } from 'c12';
6
- import { WatchOptions } from 'chokidar';
7
- import { InputOptions, OutputOptions } from 'rollup';
5
+ import { RolldownOptions, WatchOptions, InputOptions, OutputOptions } from 'rolldown';
8
6
 
9
7
  type DeepPartial<T> = T extends Record<string, any> ? {
10
8
  [P in keyof T]?: DeepPartial<T[P]> | T[P];
11
9
  } : T;
12
10
 
13
- type RollupConfig = InputOptions & {
14
- output: OutputOptions;
15
- };
16
-
17
11
  interface ApibaraHooks {
18
- "rollup:before": (apibara: Apibara, rollupConfig: RollupConfig) => void;
12
+ "rolldown:before": (apibara: Apibara, rolldownConfig: RolldownOptions) => void;
19
13
  compiled: (apibara: Apibara) => void;
20
- "dev:restart": () => void;
21
- "dev:reload": () => void;
22
- "rollup:reload": () => void;
14
+ "dev:restart": () => Promise<void>;
15
+ "dev:reload": () => Promise<void>;
16
+ "rolldown:reload": () => Promise<void>;
23
17
  restart: () => void;
24
18
  close: () => void;
25
19
  }
26
20
 
27
- type LoggerFactory = ({ indexer, preset, }: {
21
+ type RegisterFn = () => Promise<void>;
22
+ type LoggerFactoryFn = ({ indexer, indexers, preset, }: LoggerFactoryArgs) => ConsolaReporter;
23
+ type LoggerFactoryArgs = {
28
24
  indexer: string;
29
25
  indexers: string[];
30
26
  preset?: string;
31
- }) => ConsolaReporter;
27
+ };
32
28
  /**
33
29
  * Apibara Config type (apibara.config)
34
30
  */
@@ -36,9 +32,8 @@ interface ApibaraConfig<T extends Record<string, DeepPartial<Pick<ApibaraConfig<
36
32
  runtimeConfig?: R;
37
33
  presets?: T;
38
34
  preset?: keyof T;
39
- logger?: LoggerFactory;
40
35
  }
41
- type ApibaraDynamicConfig = Pick<ApibaraConfig, "runtimeConfig">;
36
+ type ApibaraDynamicConfig = Pick<ApibaraConfig, "runtimeConfig" | "preset" | "presets">;
42
37
  /**
43
38
  * Config loader options
44
39
  */
@@ -57,14 +52,19 @@ interface ApibaraOptions<T extends Record<string, DeepPartial<Pick<ApibaraConfig
57
52
  buildDir: string;
58
53
  outputDir: string;
59
54
  indexersDir: string;
55
+ disableLogs?: boolean;
60
56
  dev: boolean;
61
- watchOptions: WatchOptions;
57
+ watchOptions: WatchOptions["watch"];
62
58
  hooks: NestedHooks<ApibaraHooks>;
63
- logger?: LoggerFactory;
64
- rollupConfig?: Partial<RollupConfig>;
59
+ rolldownConfig?: Partial<RolldownOptions>;
60
+ /**
61
+ * @deprecated Use rolldownConfig instead. This option will be removed in future releases.
62
+ */
63
+ rollupConfig?: unknown;
65
64
  sourceMap?: boolean;
66
65
  entry: string;
67
- commonJS?: RollupCommonJSOptions;
66
+ node: boolean;
67
+ exportConditions?: string[];
68
68
  typescript: {
69
69
  strict?: boolean;
70
70
  internalPaths?: boolean;
@@ -85,6 +85,10 @@ interface Apibara {
85
85
  updateConfig: (config: ApibaraDynamicConfig) => void | Promise<void>;
86
86
  }
87
87
 
88
+ type RolldownConfig = InputOptions & {
89
+ output: OutputOptions;
90
+ };
91
+
88
92
  type ApibaraRuntimeConfig = Record<string, unknown>;
89
93
 
90
- export type { Apibara, ApibaraConfig, ApibaraDynamicConfig, ApibaraHooks, ApibaraOptions, ApibaraRuntimeConfig, DeepPartial, IndexerDefinition, LoadConfigOptions, LoggerFactory, RollupConfig };
94
+ export type { Apibara, ApibaraConfig, ApibaraDynamicConfig, ApibaraHooks, ApibaraOptions, ApibaraRuntimeConfig, DeepPartial, IndexerDefinition, LoadConfigOptions, LoggerFactoryArgs, LoggerFactoryFn, RegisterFn, RolldownConfig };
@@ -1 +1,2 @@
1
1
 
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apibara",
3
- "version": "2.1.0-beta.4",
3
+ "version": "2.1.0-beta.41",
4
4
  "type": "module",
5
5
  "main": "./dist/core/index.mjs",
6
6
  "exports": {
@@ -20,9 +20,9 @@
20
20
  "types": "./dist/core/index.d.ts",
21
21
  "import": "./dist/core/index.mjs"
22
22
  },
23
- "./rollup": {
24
- "types": "./dist/rollup/index.d.ts",
25
- "import": "./dist/rollup/index.mjs"
23
+ "./rolldown": {
24
+ "types": "./dist/rolldown/index.d.ts",
25
+ "import": "./dist/rolldown/index.mjs"
26
26
  },
27
27
  "./types": {
28
28
  "types": "./dist/types/index.d.ts",
@@ -32,6 +32,10 @@
32
32
  "types": "./dist/hooks/index.d.ts",
33
33
  "import": "./dist/hooks/index.mjs"
34
34
  },
35
+ "./common": {
36
+ "types": "./dist/common/index.d.ts",
37
+ "import": "./dist/common/index.mjs"
38
+ },
35
39
  "./runtime": {
36
40
  "types": "./dist/runtime/index.d.ts",
37
41
  "import": "./dist/runtime/index.mjs"
@@ -51,6 +55,22 @@
51
55
  "./dist/runtime/*": {
52
56
  "types": "./dist/runtime/*.d.ts",
53
57
  "import": "./dist/runtime/*.mjs"
58
+ },
59
+ "./indexer": {
60
+ "types": "./dist/indexer/index.d.ts",
61
+ "import": "./dist/indexer/index.mjs"
62
+ },
63
+ "./plugins": {
64
+ "types": "./dist/indexer/plugins.d.ts",
65
+ "import": "./dist/indexer/plugins.mjs"
66
+ },
67
+ "./testing": {
68
+ "types": "./dist/indexer/testing.d.ts",
69
+ "import": "./dist/indexer/testing.mjs"
70
+ },
71
+ "./vcr": {
72
+ "types": "./dist/indexer/vcr.d.ts",
73
+ "import": "./dist/indexer/vcr.mjs"
54
74
  }
55
75
  },
56
76
  "bin": {
@@ -73,10 +93,12 @@
73
93
  "playground:prepare": "pnpm playground prepare --dir playground",
74
94
  "playground:dev": "pnpm playground dev --dir playground",
75
95
  "playground:build": "pnpm playground build --dir playground",
76
- "playground:start": "pnpm playground start --dir playground --indexer starknet"
96
+ "playground:start": "pnpm playground start --dir playground --indexer starknet",
97
+ "playground:init": "pnpm playground init playground",
98
+ "playground:add": "pnpm playground add --dir playground"
77
99
  },
78
100
  "devDependencies": {
79
- "@apibara/starknet": "2.1.0-beta.4",
101
+ "@apibara/starknet": "2.1.0-beta.41",
80
102
  "@types/fs-extra": "^11.0.4",
81
103
  "@types/node": "^20.14.0",
82
104
  "@types/prompts": "^2.4.9",
@@ -87,19 +109,15 @@
87
109
  "vitest": "^1.6.0"
88
110
  },
89
111
  "dependencies": {
90
- "@apibara/indexer": "2.1.0-beta.4",
91
- "@apibara/protocol": "2.1.0-beta.4",
92
- "@rollup/plugin-commonjs": "^26.0.1",
93
- "@rollup/plugin-json": "^6.1.0",
94
- "@rollup/plugin-node-resolve": "^15.2.3",
95
- "@rollup/plugin-typescript": "^11.1.6",
112
+ "@apibara/indexer": "2.1.0-beta.41",
113
+ "@apibara/protocol": "2.1.0-beta.41",
114
+ "@rollup/plugin-replace": "^6.0.2",
96
115
  "@rollup/plugin-virtual": "^3.0.2",
97
116
  "c12": "^1.11.1",
98
117
  "chokidar": "^3.6.0",
99
118
  "citty": "^0.1.6",
100
- "consola": "^3.2.3",
119
+ "consola": "^3.4.2",
101
120
  "defu": "^6.1.4",
102
- "esbuild": "^0.23.0",
103
121
  "fs-extra": "^11.2.0",
104
122
  "hookable": "^5.5.3",
105
123
  "klona": "^2.0.6",
@@ -111,8 +129,7 @@
111
129
  "pkg-types": "^1.1.3",
112
130
  "prettier": "^3.5.2",
113
131
  "prompts": "^2.4.2",
114
- "rollup": "^4.18.1",
115
- "rollup-plugin-esbuild": "^6.1.1",
132
+ "rolldown": "1.0.0-beta.3",
116
133
  "ts-morph": "^25.0.1",
117
134
  "tslib": "^2.6.3",
118
135
  "untyped": "^1.4.2"
@@ -1,3 +1,4 @@
1
+ import { checkForUnknownArgs } from "apibara/common";
1
2
  import { addIndexer } from "apibara/create";
2
3
  import { defineCommand } from "citty";
3
4
 
@@ -10,28 +11,35 @@ export default defineCommand({
10
11
  args: {
11
12
  indexerId: {
12
13
  type: "positional",
13
- description: "Indexer ID",
14
+ description: "Indexer ID - must be in kebab-case",
14
15
  required: false,
15
16
  },
16
17
  chain: {
17
18
  type: "string",
18
- description: "Chain",
19
+ description: "Blockchain - ethereum, beaconchain, starknet",
19
20
  },
20
21
  network: {
21
22
  type: "string",
22
- description: "Network",
23
+ description: "Network - mainnet, sepolia, other",
23
24
  },
24
25
  storage: {
25
26
  type: "string",
26
- description: "Storage",
27
+ description: "Storage - postgres, none",
27
28
  },
28
29
  dnaUrl: {
29
30
  type: "string",
30
- description: "DNA URL",
31
+ description: "DNA URL - https://custom-dna-url.apibara.org",
32
+ },
33
+ dir: {
34
+ type: "string",
35
+ description:
36
+ "Root directory - apibara project root where apibara.config is located | default: current working directory",
31
37
  },
32
38
  },
33
- async run({ args }) {
34
- const { indexerId, chain, network, storage, dnaUrl } = args;
39
+ async run({ args, cmd }) {
40
+ await checkForUnknownArgs(args, cmd);
41
+
42
+ const { indexerId, chain, network, storage, dnaUrl, dir } = args;
35
43
 
36
44
  await addIndexer({
37
45
  argIndexerId: indexerId,
@@ -39,6 +47,7 @@ export default defineCommand({
39
47
  argNetwork: network,
40
48
  argStorage: storage,
41
49
  argDnaUrl: dnaUrl,
50
+ argRootDir: dir,
42
51
  });
43
52
  },
44
53
  });
@@ -1,8 +1,8 @@
1
+ import { checkForUnknownArgs, commonArgs } from "apibara/common";
1
2
  import { build, createApibara, prepare, writeTypes } from "apibara/core";
2
3
  import { runtimeDir } from "apibara/runtime/meta";
3
4
  import { defineCommand } from "citty";
4
5
  import { join, resolve } from "pathe";
5
- import { commonArgs } from "../common";
6
6
 
7
7
  export default defineCommand({
8
8
  meta: {
@@ -12,8 +12,11 @@ export default defineCommand({
12
12
  args: {
13
13
  ...commonArgs,
14
14
  },
15
- async run({ args }) {
15
+ async run({ args, cmd }) {
16
+ await checkForUnknownArgs(args, cmd);
17
+
16
18
  const rootDir = resolve((args.dir || args._dir || ".") as string);
19
+
17
20
  const apibara = await createApibara({
18
21
  rootDir,
19
22
  });