apibara 2.0.0-beta.4 → 2.0.0-beta.40

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 (68) hide show
  1. package/dist/chunks/build.mjs +28 -0
  2. package/dist/chunks/dev.mjs +100 -0
  3. package/dist/chunks/prepare.mjs +21 -0
  4. package/dist/chunks/start.mjs +56 -0
  5. package/dist/cli/index.d.mts +5 -0
  6. package/dist/cli/index.d.ts +5 -0
  7. package/dist/cli/index.mjs +19 -0
  8. package/dist/config/index.d.mts +5 -0
  9. package/dist/config/index.d.ts +5 -0
  10. package/dist/config/index.mjs +5 -0
  11. package/dist/core/index.d.mts +11 -0
  12. package/dist/core/index.d.ts +11 -0
  13. package/dist/core/index.mjs +310 -0
  14. package/dist/hooks/index.d.mts +5 -0
  15. package/dist/hooks/index.d.ts +5 -0
  16. package/dist/hooks/index.mjs +5 -0
  17. package/dist/rollup/index.d.mts +5 -0
  18. package/dist/rollup/index.d.ts +5 -0
  19. package/dist/rollup/index.mjs +150 -0
  20. package/dist/runtime/dev.d.ts +3 -0
  21. package/dist/runtime/dev.mjs +55 -0
  22. package/dist/runtime/index.d.ts +2 -0
  23. package/dist/runtime/index.mjs +2 -0
  24. package/dist/runtime/internal/app.d.ts +2 -0
  25. package/dist/runtime/internal/app.mjs +56 -0
  26. package/dist/runtime/internal/logger.d.ts +14 -0
  27. package/dist/runtime/internal/logger.mjs +45 -0
  28. package/dist/runtime/start.d.ts +3 -0
  29. package/dist/runtime/start.mjs +41 -0
  30. package/dist/shared/apibara.1b515d04.mjs +8 -0
  31. package/dist/types/index.d.mts +90 -0
  32. package/dist/types/index.d.ts +90 -0
  33. package/dist/types/index.mjs +1 -0
  34. package/package.json +28 -8
  35. package/runtime-meta.d.ts +2 -0
  36. package/runtime-meta.mjs +7 -0
  37. package/src/cli/commands/build.ts +5 -3
  38. package/src/cli/commands/dev.ts +29 -19
  39. package/src/cli/commands/prepare.ts +0 -2
  40. package/src/cli/commands/start.ts +61 -0
  41. package/src/cli/index.ts +1 -0
  42. package/src/config/index.ts +5 -4
  43. package/src/core/apibara.ts +4 -2
  44. package/src/core/build/build.ts +2 -0
  45. package/src/core/build/dev.ts +1 -0
  46. package/src/core/build/prepare.ts +5 -2
  47. package/src/core/build/prod.ts +10 -6
  48. package/src/core/build/types.ts +4 -95
  49. package/src/core/config/defaults.ts +1 -4
  50. package/src/core/config/loader.ts +1 -0
  51. package/src/core/config/resolvers/runtime-config.resolver.ts +1 -1
  52. package/src/core/config/update.ts +2 -3
  53. package/src/core/path.ts +11 -0
  54. package/src/core/scan.ts +40 -0
  55. package/src/rollup/config.ts +67 -188
  56. package/src/rollup/plugins/config.ts +12 -0
  57. package/src/rollup/plugins/esm-shim.ts +69 -0
  58. package/src/rollup/plugins/indexers.ts +17 -0
  59. package/src/runtime/dev.ts +64 -0
  60. package/src/runtime/index.ts +2 -0
  61. package/src/runtime/internal/app.ts +78 -0
  62. package/src/runtime/internal/logger.ts +70 -0
  63. package/src/runtime/start.ts +48 -0
  64. package/src/types/apibara.ts +8 -0
  65. package/src/types/config.ts +28 -27
  66. package/src/types/hooks.ts +1 -0
  67. package/src/types/virtual/config.d.ts +3 -0
  68. package/src/types/virtual/indexers.d.ts +10 -0
@@ -1,4 +1,5 @@
1
- import type { Sink } from "@apibara/indexer";
1
+ import type { ConsolaReporter } from "@apibara/indexer/plugins";
2
+ import type { RollupCommonJSOptions } from "@rollup/plugin-commonjs";
2
3
  import type {
3
4
  C12InputConfig,
4
5
  ConfigWatcher,
@@ -7,28 +8,30 @@ import type {
7
8
  } from "c12";
8
9
  import type { WatchOptions } from "chokidar";
9
10
  import type { NestedHooks } from "hookable";
10
- import type { TSConfig } from "pkg-types";
11
11
  import type { DeepPartial } from "./_utils";
12
12
  import type { ApibaraHooks } from "./hooks";
13
13
  import type { RollupConfig } from "./rollup";
14
14
 
15
+ export type LoggerFactory = ({
16
+ indexer,
17
+ preset,
18
+ }: { indexer: string; indexers: string[]; preset?: string }) => ConsolaReporter;
19
+
15
20
  /**
16
21
  * Apibara Config type (apibara.config)
17
22
  */
18
23
  export interface ApibaraConfig<
19
- // biome-ignore lint/complexity/noBannedTypes: <explanation>
20
- T extends Record<string, DeepPartial<ApibaraConfig<T, R>>> = {},
21
- // biome-ignore lint/complexity/noBannedTypes: <explanation>
22
- R extends Record<string, unknown> = {},
23
- > extends DeepPartial<Omit<ApibaraOptions<T, R>, "preset" | "presets" | "dev">>,
24
+ T extends Record<
25
+ string,
26
+ DeepPartial<Pick<ApibaraConfig<T, R>, "runtimeConfig">>
27
+ > = Record<string, never>,
28
+ R extends Record<string, unknown> = Record<string, never>,
29
+ > extends Partial<Omit<ApibaraOptions<T, R>, "preset" | "presets" | "dev">>,
24
30
  C12InputConfig<ApibaraConfig<T, R>> {
25
- sink?: {
26
- default: () => Sink;
27
- [key: string]: () => Sink;
28
- };
29
31
  runtimeConfig?: R;
30
32
  presets?: T;
31
33
  preset?: keyof T;
34
+ logger?: LoggerFactory;
32
35
  }
33
36
 
34
37
  export type ApibaraDynamicConfig = Pick<ApibaraConfig, "runtimeConfig">;
@@ -42,10 +45,11 @@ export interface LoadConfigOptions {
42
45
  }
43
46
 
44
47
  export interface ApibaraOptions<
45
- // biome-ignore lint/complexity/noBannedTypes: <explanation>
46
- T extends Record<string, DeepPartial<ApibaraConfig<T, R>>> = {},
47
- // biome-ignore lint/complexity/noBannedTypes: <explanation>
48
- R extends Record<string, unknown> = {},
48
+ T extends Record<
49
+ string,
50
+ DeepPartial<Pick<ApibaraConfig<T, R>, "runtimeConfig">>
51
+ > = Record<string, never>,
52
+ R extends Record<string, unknown> = Record<string, never>,
49
53
  > {
50
54
  // Internal
51
55
  _config: ApibaraConfig<T, R>;
@@ -53,12 +57,6 @@ export interface ApibaraOptions<
53
57
  | ResolvedConfig<ApibaraConfig<T, R>>
54
58
  | ConfigWatcher<ApibaraConfig<T, R>>;
55
59
 
56
- // Sink
57
- sink: {
58
- default: () => Sink;
59
- [key: string]: () => Sink;
60
- };
61
-
62
60
  // Presets
63
61
  presets?: T;
64
62
  preset?: keyof T;
@@ -69,25 +67,28 @@ export interface ApibaraOptions<
69
67
  rootDir: string;
70
68
  buildDir: string;
71
69
  outputDir: string;
70
+ indexersDir: string;
71
+
72
72
  // Dev
73
73
  dev: boolean;
74
74
  watchOptions: WatchOptions;
75
75
 
76
76
  // Hooks
77
77
  hooks: NestedHooks<ApibaraHooks>;
78
+
79
+ // Logging
80
+ logger?: LoggerFactory;
81
+
78
82
  // Rollup
79
- rollupConfig?: RollupConfig;
83
+ rollupConfig?: Partial<RollupConfig>;
84
+ sourceMap?: boolean;
80
85
  entry: string;
81
- minify: boolean;
86
+ commonJS?: RollupCommonJSOptions;
82
87
 
83
88
  // Advanced
84
89
  typescript: {
85
90
  strict?: boolean;
86
91
  internalPaths?: boolean;
87
92
  generateRuntimeConfigTypes?: boolean;
88
- generateTsConfig?: boolean;
89
- /** the path of the generated `tsconfig.json`, relative to buildDir */
90
- tsconfigPath: string;
91
- tsConfig?: Partial<TSConfig>;
92
93
  };
93
94
  }
@@ -4,6 +4,7 @@ import type { RollupConfig } from "./rollup";
4
4
  export interface ApibaraHooks {
5
5
  "rollup:before": (apibara: Apibara, rollupConfig: RollupConfig) => void;
6
6
  compiled: (apibara: Apibara) => void;
7
+ "dev:restart": () => void;
7
8
  "dev:reload": () => void;
8
9
  "rollup:reload": () => void;
9
10
  restart: () => void;
@@ -0,0 +1,3 @@
1
+ import type { ApibaraConfig } from "apibara/types";
2
+
3
+ export const config: ApibaraConfig = {};
@@ -0,0 +1,10 @@
1
+ import type { IndexerWithStreamConfig } from "@apibara/indexer";
2
+ import type { ApibaraRuntimeConfig } from "apibara/types";
3
+
4
+ export type IndexerConstructor =
5
+ | ((
6
+ runtimeConfig: ApibaraRuntimeConfig,
7
+ ) => IndexerWithStreamConfig<unknown, unknown, unknown>)
8
+ | IndexerWithStreamConfig<unknown, unknown, unknown>;
9
+
10
+ export const indexers: { name: string; indexer: IndexerConstructor }[] = [];