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.
- package/dist/chunks/build.mjs +28 -0
- package/dist/chunks/dev.mjs +100 -0
- package/dist/chunks/prepare.mjs +21 -0
- package/dist/chunks/start.mjs +56 -0
- package/dist/cli/index.d.mts +5 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.mjs +19 -0
- package/dist/config/index.d.mts +5 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.mjs +5 -0
- package/dist/core/index.d.mts +11 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.mjs +310 -0
- package/dist/hooks/index.d.mts +5 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.mjs +5 -0
- package/dist/rollup/index.d.mts +5 -0
- package/dist/rollup/index.d.ts +5 -0
- package/dist/rollup/index.mjs +150 -0
- package/dist/runtime/dev.d.ts +3 -0
- package/dist/runtime/dev.mjs +55 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.mjs +2 -0
- package/dist/runtime/internal/app.d.ts +2 -0
- package/dist/runtime/internal/app.mjs +56 -0
- package/dist/runtime/internal/logger.d.ts +14 -0
- package/dist/runtime/internal/logger.mjs +45 -0
- package/dist/runtime/start.d.ts +3 -0
- package/dist/runtime/start.mjs +41 -0
- package/dist/shared/apibara.1b515d04.mjs +8 -0
- package/dist/types/index.d.mts +90 -0
- package/dist/types/index.d.ts +90 -0
- package/dist/types/index.mjs +1 -0
- package/package.json +28 -8
- package/runtime-meta.d.ts +2 -0
- package/runtime-meta.mjs +7 -0
- package/src/cli/commands/build.ts +5 -3
- package/src/cli/commands/dev.ts +29 -19
- package/src/cli/commands/prepare.ts +0 -2
- package/src/cli/commands/start.ts +61 -0
- package/src/cli/index.ts +1 -0
- package/src/config/index.ts +5 -4
- package/src/core/apibara.ts +4 -2
- package/src/core/build/build.ts +2 -0
- package/src/core/build/dev.ts +1 -0
- package/src/core/build/prepare.ts +5 -2
- package/src/core/build/prod.ts +10 -6
- package/src/core/build/types.ts +4 -95
- package/src/core/config/defaults.ts +1 -4
- package/src/core/config/loader.ts +1 -0
- package/src/core/config/resolvers/runtime-config.resolver.ts +1 -1
- package/src/core/config/update.ts +2 -3
- package/src/core/path.ts +11 -0
- package/src/core/scan.ts +40 -0
- package/src/rollup/config.ts +67 -188
- package/src/rollup/plugins/config.ts +12 -0
- package/src/rollup/plugins/esm-shim.ts +69 -0
- package/src/rollup/plugins/indexers.ts +17 -0
- package/src/runtime/dev.ts +64 -0
- package/src/runtime/index.ts +2 -0
- package/src/runtime/internal/app.ts +78 -0
- package/src/runtime/internal/logger.ts +70 -0
- package/src/runtime/start.ts +48 -0
- package/src/types/apibara.ts +8 -0
- package/src/types/config.ts +28 -27
- package/src/types/hooks.ts +1 -0
- package/src/types/virtual/config.d.ts +3 -0
- package/src/types/virtual/indexers.d.ts +10 -0
package/src/types/config.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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
|
}
|
package/src/types/hooks.ts
CHANGED
|
@@ -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,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 }[] = [];
|