plantr 2.0.0 → 2.1.0
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/index.d.ts +23 -20
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +761 -262
- package/dist/src/cli.d.ts +13 -3
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/create-seeder-instance.d.ts +55 -78
- package/dist/src/create-seeder-instance.d.ts.map +1 -0
- package/dist/src/define-seeder.d.ts +4 -3
- package/dist/src/define-seeder.d.ts.map +1 -0
- package/dist/src/dependency-resolver.d.ts +2 -1
- package/dist/src/dependency-resolver.d.ts.map +1 -0
- package/dist/src/formatting.d.ts +27 -13
- package/dist/src/formatting.d.ts.map +1 -0
- package/dist/src/lazy-faker.d.ts +12 -0
- package/dist/src/lazy-faker.d.ts.map +1 -0
- package/dist/src/run-seeders.d.ts +39 -22
- package/dist/src/run-seeders.d.ts.map +1 -0
- package/dist/src/seeding-state.d.ts +15 -4
- package/dist/src/seeding-state.d.ts.map +1 -0
- package/dist/src/step.d.ts +79 -22
- package/dist/src/step.d.ts.map +1 -0
- package/dist/src/types.d.ts +117 -34
- package/dist/src/types.d.ts.map +1 -0
- package/dist/state.d.ts +2 -1
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +10 -2
- package/index.ts +56 -23
- package/package.json +2 -1
- package/readme.md +89 -48
- package/src/cli.ts +154 -21
- package/src/create-seeder-instance.ts +225 -110
- package/src/define-seeder.ts +14 -7
- package/src/dependency-resolver.ts +17 -28
- package/src/formatting.ts +121 -36
- package/src/lazy-faker.ts +46 -0
- package/src/run-seeders.ts +336 -115
- package/src/seeding-state.ts +27 -5
- package/src/step.ts +208 -64
- package/src/types.ts +169 -37
- package/state.ts +1 -1
package/dist/src/step.d.ts
CHANGED
|
@@ -1,55 +1,112 @@
|
|
|
1
|
+
import type { JsonValue, MaybePromise } from './types.js';
|
|
2
|
+
/** Envelope written to `SeederCache.set` / `SeederCache.setMany` by plantr */
|
|
3
|
+
export type CacheEntry = {
|
|
4
|
+
readonly __plantr: 1;
|
|
5
|
+
readonly version?: string;
|
|
6
|
+
readonly value?: unknown;
|
|
7
|
+
};
|
|
8
|
+
/** Single entry passed to `SeederCache.setMany` */
|
|
9
|
+
export type CacheWrite = {
|
|
10
|
+
readonly key: string;
|
|
11
|
+
readonly value: CacheEntry;
|
|
12
|
+
};
|
|
1
13
|
export type StepOptions = {
|
|
2
14
|
/** Enable caching for this step */
|
|
3
|
-
useCache?:
|
|
15
|
+
useCache?: false | undefined;
|
|
16
|
+
version?: never;
|
|
17
|
+
key?: never;
|
|
18
|
+
} | {
|
|
19
|
+
/** Enable caching for this step */
|
|
20
|
+
useCache: true;
|
|
21
|
+
/**
|
|
22
|
+
* Optional explicit cache key (scoped to the seeder name).
|
|
23
|
+
* Defaults to a slugified version of the step description.
|
|
24
|
+
* Use this when you want to reword a description without busting the cache,
|
|
25
|
+
* or when the description contains non-ASCII characters.
|
|
26
|
+
*/
|
|
27
|
+
key?: string | undefined;
|
|
4
28
|
/**
|
|
5
29
|
* Any JSON value describing what the step's output depends on (a number you bump,
|
|
6
30
|
* the data the step writes). A cached entry stored with a different version is a
|
|
7
|
-
* miss: the step runs again and its entry is overwritten.
|
|
31
|
+
* miss: the step runs again and its entry is overwritten. Object keys are compared
|
|
32
|
+
* deterministically regardless of insertion order.
|
|
8
33
|
*/
|
|
9
|
-
version?:
|
|
34
|
+
version?: JsonValue | undefined;
|
|
10
35
|
};
|
|
11
|
-
export type StepFn = <T>(description: string, fn: () =>
|
|
36
|
+
export type StepFn = <T>(description: string, fn: () => MaybePromise<T>, options?: StepOptions) => Promise<T>;
|
|
12
37
|
/**
|
|
13
38
|
* Cache interface for step caching.
|
|
14
|
-
* Provide get/set functions to enable caching in the step runner.
|
|
39
|
+
* Provide `get` / `set` functions to enable caching in the step runner.
|
|
15
40
|
* plantr stores an envelope object (`{ __plantr: 1, version?, value }`), so `set`
|
|
16
|
-
* always receives
|
|
41
|
+
* always receives a `CacheEntry` and `get` should return it as stored (or `undefined`/`null` on miss).
|
|
42
|
+
*
|
|
43
|
+
* Optionally provide `getAll` to preload all entries in one query at the start of a run,
|
|
44
|
+
* and `setMany` to flush new/updated entries in one batch write at the end of a run.
|
|
17
45
|
*/
|
|
18
46
|
export type SeederCache = {
|
|
19
|
-
/** Get a cached value by key.
|
|
20
|
-
get:
|
|
47
|
+
/** Get a cached value by key. Return undefined or null if not found. */
|
|
48
|
+
get: (key: string) => MaybePromise<unknown>;
|
|
21
49
|
/** Set a cached value by key. */
|
|
22
|
-
set:
|
|
50
|
+
set: (key: string, value: CacheEntry) => MaybePromise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Optional: load all cached entries once at the start of a run to avoid N+1 `get` queries.
|
|
53
|
+
*/
|
|
54
|
+
getAll?: (() => MaybePromise<Map<string, unknown> | Record<string, unknown>>) | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Optional: write all new/updated cache entries in a single batch at the end of a run
|
|
57
|
+
* (before `onAfterAll`), removing per-step write round-trips from the critical path.
|
|
58
|
+
*/
|
|
59
|
+
setMany?: ((entries: readonly CacheWrite[]) => MaybePromise<void>) | undefined;
|
|
23
60
|
};
|
|
24
61
|
/** What the steps of the current seeder did, for error reporting */
|
|
25
62
|
export type StepRecord = {
|
|
26
63
|
/** Descriptions of the steps whose output came from the cache */
|
|
27
64
|
cachedSteps: string[];
|
|
28
|
-
/** Description and error of the
|
|
65
|
+
/** Description and error of the innermost step that threw */
|
|
29
66
|
failed?: {
|
|
30
67
|
step: string;
|
|
31
68
|
error: unknown;
|
|
32
69
|
};
|
|
33
70
|
};
|
|
34
|
-
|
|
35
|
-
|
|
71
|
+
/** Isolated execution scope for a single seeder's steps (concurrency-safe) */
|
|
72
|
+
export type StepScope = {
|
|
73
|
+
seederName: string;
|
|
74
|
+
fresh: boolean;
|
|
75
|
+
record: StepRecord;
|
|
76
|
+
prefix?: string | undefined;
|
|
77
|
+
};
|
|
78
|
+
export type StepRunnerConfig = {
|
|
79
|
+
cache?: SeederCache | undefined;
|
|
36
80
|
/** Seeder name for scoping cache keys */
|
|
37
|
-
seederName?: string;
|
|
81
|
+
seederName?: string | undefined;
|
|
38
82
|
/** Print a line per step (default: true) */
|
|
39
|
-
log?: boolean;
|
|
83
|
+
log?: boolean | undefined;
|
|
40
84
|
};
|
|
41
|
-
|
|
42
|
-
* Create a step runner for organizing seeder workflow.
|
|
43
|
-
* Optionally provide a cache for step caching support.
|
|
44
|
-
*/
|
|
45
|
-
export declare function createStepRunner(config?: StepRunnerConfig): {
|
|
85
|
+
export type StepRunner = {
|
|
46
86
|
step: StepFn;
|
|
47
87
|
/**
|
|
48
|
-
* Start a seeder: scopes cache keys to its name and returns the
|
|
49
|
-
* With `fresh`, its cached steps ignore stored entries and overwrite them.
|
|
88
|
+
* Start a seeder in sequential mode: scopes cache keys to its name and returns the
|
|
89
|
+
* record its steps fill. With `fresh`, its cached steps ignore stored entries and overwrite them.
|
|
50
90
|
*/
|
|
51
91
|
setSeederName: (name: string, options?: {
|
|
52
92
|
fresh?: boolean;
|
|
53
93
|
}) => StepRecord;
|
|
94
|
+
/** Create an isolated scope for running one seeder concurrently */
|
|
95
|
+
createScope: (options: {
|
|
96
|
+
seederName: string;
|
|
97
|
+
fresh?: boolean;
|
|
98
|
+
prefix?: string;
|
|
99
|
+
}) => StepScope;
|
|
100
|
+
/** Run an async callback with `scope` bound via AsyncLocalStorage */
|
|
101
|
+
runWithScope: <T>(scope: StepScope, fn: () => Promise<T>) => Promise<T>;
|
|
102
|
+
/** Preload cache entries via `cache.getAll()` if configured */
|
|
103
|
+
preload: () => Promise<void>;
|
|
104
|
+
/** Flush buffered cache writes via `cache.setMany()` if configured */
|
|
105
|
+
flush: () => Promise<void>;
|
|
54
106
|
};
|
|
55
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Create a step runner for organizing seeder workflow.
|
|
109
|
+
* Optionally provide a cache for step caching support.
|
|
110
|
+
*/
|
|
111
|
+
export declare function createStepRunner(config?: StepRunnerConfig): StepRunner;
|
|
112
|
+
//# sourceMappingURL=step.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/step.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEzD,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA;IACpB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA;AAED,mDAAmD;AACnD,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,WAAW,GACpB;IACA,mCAAmC;IACnC,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;IAC5B,OAAO,CAAC,EAAE,KAAK,CAAA;IACf,GAAG,CAAC,EAAE,KAAK,CAAA;CACV,GACD;IACA,mCAAmC;IACnC,QAAQ,EAAE,IAAI,CAAA;IACd;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;CAC9B,CAAA;AAEJ,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,EACtB,WAAW,EAAE,MAAM,EACnB,EAAE,EAAE,MAAM,YAAY,CAAC,CAAC,CAAC,EACzB,OAAO,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,CAAC,CAAC,CAAA;AAEf;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG;IACzB,wEAAwE;IACxE,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,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AAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,UAAU,CAAA;IAC1E,mEAAmE;IACnE,WAAW,EAAE,CAAC,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,SAAS,CAAA;IAC7F,qEAAqE;IACrE,YAAY,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;IACvE,+DAA+D;IAC/D,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5B,sEAAsE;IACtE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1B,CAAA;AAkCD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,UAAU,CAoJtE"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -5,8 +5,20 @@
|
|
|
5
5
|
* Consumers can extend this with their own context (e.g. prisma, custom helpers).
|
|
6
6
|
*/
|
|
7
7
|
import type { expect } from 'bun:test';
|
|
8
|
-
import type {
|
|
9
|
-
import type { StepFn } from './step';
|
|
8
|
+
import type { Faker } from '@faker-js/faker';
|
|
9
|
+
import type { StepFn } from './step.js';
|
|
10
|
+
/** Flatten intersections and mapped types for cleaner IDE hover tooltips */
|
|
11
|
+
export type Prettify<T> = {
|
|
12
|
+
[K in keyof T]: T[K];
|
|
13
|
+
} & {};
|
|
14
|
+
/** A value or a Promise resolving to that value */
|
|
15
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
16
|
+
/** JSON-serializable primitive */
|
|
17
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
18
|
+
/** JSON-serializable value (used for step cache versions) */
|
|
19
|
+
export type JsonValue = JsonPrimitive | readonly JsonValue[] | {
|
|
20
|
+
readonly [key: string]: JsonValue | undefined;
|
|
21
|
+
};
|
|
10
22
|
/**
|
|
11
23
|
* Base seeder context provided by the library.
|
|
12
24
|
* Contains faker for generating test data, step for workflow organization,
|
|
@@ -14,84 +26,155 @@ import type { StepFn } from './step';
|
|
|
14
26
|
*/
|
|
15
27
|
export type BaseSeederContext = {
|
|
16
28
|
/** Faker instance for generating test data */
|
|
17
|
-
faker:
|
|
29
|
+
faker: Faker;
|
|
18
30
|
/** Step function for organizing seeder workflow */
|
|
19
31
|
step: StepFn;
|
|
20
32
|
/** Assertion function from bun:test for verifying data */
|
|
21
33
|
expect: typeof expect;
|
|
22
34
|
};
|
|
23
35
|
/** Extract the output type from a Seeder */
|
|
24
|
-
export type SeederOutput<T> = T extends Seeder<any,
|
|
36
|
+
export type SeederOutput<T> = T extends Seeder<any, any, infer O, any> ? O : never;
|
|
25
37
|
/** Extract the name from a Seeder */
|
|
26
|
-
export type SeederName<T> = T extends Seeder<any, infer N,
|
|
38
|
+
export type SeederName<T> = T extends Seeder<any, infer N, any, any> ? N : never;
|
|
39
|
+
/** Extract the dependency names from a Seeder */
|
|
40
|
+
export type SeederDeps<T> = T extends Seeder<any, any, any, infer D> ? D : never;
|
|
27
41
|
/** Build a typed deps object from an array of seeder dependencies */
|
|
28
|
-
export type DepsFromSeeders<T extends readonly SeederAny[]> = {
|
|
42
|
+
export type DepsFromSeeders<T extends readonly SeederAny[]> = Prettify<{
|
|
29
43
|
[K in T[number] as SeederName<K>]: SeederOutput<K>;
|
|
44
|
+
}>;
|
|
45
|
+
/** Map of seeder name -> output type for a collection of seeders */
|
|
46
|
+
export type SeederOutputs<TSeeders extends readonly SeederAny[]> = Prettify<{
|
|
47
|
+
[K in TSeeders[number] as SeederName<K>]: SeederOutput<K>;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Dependency names required by seeders in `TSeeders` that are not present in `TSeeders`.
|
|
51
|
+
* Evaluates to `never` when all dependencies are present or when names are widened to `string`.
|
|
52
|
+
*/
|
|
53
|
+
export type MissingSeederDeps<TSeeders extends readonly SeederAny[]> = string extends SeederName<TSeeders[number]> ? never : string extends SeederDeps<TSeeders[number]> ? never : Exclude<SeederDeps<TSeeders[number]>, SeederName<TSeeders[number]>>;
|
|
54
|
+
/**
|
|
55
|
+
* Compile-time constraint verifying that every dependency declared by a seeder in `TSeeders`
|
|
56
|
+
* is also included in `TSeeders`.
|
|
57
|
+
*/
|
|
58
|
+
export type ValidateSeeders<TSeeders extends readonly SeederAny[]> = [
|
|
59
|
+
MissingSeederDeps<TSeeders>
|
|
60
|
+
] extends [never] ? unknown : {
|
|
61
|
+
readonly __missingDependencies__: `Missing required seeder(s) in list: ${MissingSeederDeps<TSeeders>}`;
|
|
30
62
|
};
|
|
31
63
|
/** Configuration for creating a seeder */
|
|
32
64
|
export type SeederConfig<TContext, TName extends string, TOutput, TDeps extends readonly SeederAny[] = readonly []> = {
|
|
33
65
|
/** Unique name for the seeder */
|
|
34
66
|
name: TName;
|
|
35
67
|
/** Optional description of what the seeder does */
|
|
36
|
-
description?: string;
|
|
68
|
+
description?: string | undefined;
|
|
37
69
|
/** Seeder objects that must run before this one - provides typed outputs */
|
|
38
|
-
dependsOn?: TDeps;
|
|
39
|
-
/** The seeding function that creates data */
|
|
40
|
-
run: (ctx: TContext, deps: TDeps extends readonly never[] ? Record<string, never> : DepsFromSeeders<TDeps>) =>
|
|
70
|
+
dependsOn?: TDeps | undefined;
|
|
71
|
+
/** The seeding function that creates data (sync or async) */
|
|
72
|
+
run: (ctx: TContext, deps: TDeps extends readonly never[] ? Record<string, never> : DepsFromSeeders<TDeps>) => MaybePromise<TOutput>;
|
|
41
73
|
};
|
|
42
74
|
/** A seeder instance ready for execution */
|
|
43
|
-
export type Seeder<TContext, TName extends string = string, TOutput = unknown> = {
|
|
75
|
+
export type Seeder<TContext, TName extends string = string, TOutput = unknown, TDepNames extends string = string> = {
|
|
44
76
|
/** Unique name for the seeder */
|
|
45
|
-
name: TName;
|
|
77
|
+
readonly name: TName;
|
|
46
78
|
/** Optional description of what the seeder does */
|
|
47
|
-
description?: string;
|
|
79
|
+
readonly description?: string | undefined;
|
|
48
80
|
/** Names of seeders that must run before this one (extracted from dependsOn) */
|
|
49
|
-
dependsOn: readonly
|
|
81
|
+
readonly dependsOn: readonly TDepNames[];
|
|
50
82
|
/** The seeding function that creates data */
|
|
51
|
-
run: (ctx: TContext, deps: Record<string, unknown>) =>
|
|
83
|
+
readonly run: (ctx: TContext, deps: Record<string, unknown>) => MaybePromise<TOutput>;
|
|
52
84
|
};
|
|
53
85
|
/** Type-erased seeder for collections (can hold any seeder type) */
|
|
54
|
-
export type SeederAny = Seeder<any, string, unknown>;
|
|
55
|
-
/**
|
|
56
|
-
export type
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
86
|
+
export type SeederAny = Seeder<any, string, unknown, string>;
|
|
87
|
+
/** Result for a seeder that completed successfully */
|
|
88
|
+
export type CompletedSeederResult<TName extends string = string, TOutput = unknown> = {
|
|
89
|
+
name: TName;
|
|
90
|
+
status: 'completed';
|
|
91
|
+
durationMs: number;
|
|
92
|
+
output: TOutput;
|
|
93
|
+
/** Descriptions of the steps whose output came from the cache */
|
|
94
|
+
cachedSteps: string[];
|
|
95
|
+
};
|
|
96
|
+
/** Result for a seeder that threw an error */
|
|
97
|
+
export type FailedSeederResult<TName extends string = string> = {
|
|
98
|
+
name: TName;
|
|
99
|
+
status: 'failed';
|
|
100
|
+
durationMs: number;
|
|
101
|
+
error: Error;
|
|
64
102
|
/** Description of the step that threw, when the seeder failed in a step */
|
|
65
|
-
failedStep?: string;
|
|
103
|
+
failedStep?: string | undefined;
|
|
66
104
|
/** Descriptions of the steps whose output came from the cache */
|
|
67
|
-
cachedSteps
|
|
105
|
+
cachedSteps: string[];
|
|
106
|
+
};
|
|
107
|
+
/** Result for a seeder that was skipped because one or more dependencies failed */
|
|
108
|
+
export type SkippedSeederResult<TName extends string = string> = {
|
|
109
|
+
name: TName;
|
|
110
|
+
status: 'skipped';
|
|
111
|
+
/** Names of direct dependencies that failed or were skipped */
|
|
112
|
+
failedDeps: string[];
|
|
113
|
+
};
|
|
114
|
+
/** Result for a seeder that never started (e.g. an earlier seeder failed without continueOnFailure) */
|
|
115
|
+
export type PendingSeederResult<TName extends string = string> = {
|
|
116
|
+
name: TName;
|
|
117
|
+
status: 'pending';
|
|
68
118
|
};
|
|
119
|
+
/** Discriminated union representing the outcome of a seeder */
|
|
120
|
+
export type SeederResult<TName extends string = string, TOutput = unknown> = CompletedSeederResult<TName, TOutput> | FailedSeederResult<TName> | SkippedSeederResult<TName> | PendingSeederResult<TName>;
|
|
121
|
+
/** Status of a seeder result */
|
|
122
|
+
export type SeederStatus = SeederResult['status'];
|
|
123
|
+
/**
|
|
124
|
+
* Union of typed `SeederResult` members pairing each seeder in `TSeeders`
|
|
125
|
+
* with its literal name and output type.
|
|
126
|
+
*/
|
|
127
|
+
export type SeederResultFor<TSeeders extends readonly SeederAny[]> = TSeeders[number] extends infer S ? S extends SeederAny ? SeederResult<SeederName<S>, SeederOutput<S>> : never : never;
|
|
69
128
|
/** Options for the seeder runner */
|
|
70
|
-
export type RunSeedersOptions = {
|
|
129
|
+
export type RunSeedersOptions<TName extends string = string> = {
|
|
71
130
|
/** Whether to print the results table (default: true) */
|
|
72
|
-
printResults?: boolean;
|
|
131
|
+
printResults?: boolean | undefined;
|
|
73
132
|
/** Whether to print verbose output (default: true) */
|
|
74
|
-
verbose?: boolean;
|
|
133
|
+
verbose?: boolean | undefined;
|
|
75
134
|
/**
|
|
76
135
|
* Whether to continue running seeders after a failure (default: false).
|
|
77
136
|
* When true, seeders that depend on a failed seeder will be skipped,
|
|
78
137
|
* but independent seeders will still run.
|
|
79
138
|
*/
|
|
80
|
-
continueOnFailure?: boolean;
|
|
139
|
+
continueOnFailure?: boolean | undefined;
|
|
81
140
|
/**
|
|
82
141
|
* Run only these seeders and everything they depend on, in dependency order.
|
|
83
142
|
* Throws `UnknownSeederError` for a name that is not registered.
|
|
84
143
|
*/
|
|
85
|
-
only?: readonly
|
|
144
|
+
only?: readonly TName[] | undefined;
|
|
86
145
|
/**
|
|
87
146
|
* Ignore cached step entries and overwrite them: `true` for every seeder,
|
|
88
147
|
* or the names of the seeders to run fresh. Dependencies of those seeders still
|
|
89
148
|
* replay their cache unless they are named too.
|
|
90
149
|
*/
|
|
91
|
-
fresh?: boolean | readonly
|
|
150
|
+
fresh?: boolean | readonly TName[] | undefined;
|
|
92
151
|
/**
|
|
93
152
|
* Seed a target that is not local (see `target` on the instance config).
|
|
94
153
|
* Without it, a non-local target throws `SeedTargetError` before anything runs.
|
|
95
154
|
*/
|
|
96
|
-
allowRemote?: boolean;
|
|
155
|
+
allowRemote?: boolean | undefined;
|
|
156
|
+
/**
|
|
157
|
+
* Maximum number of independent seeders to run concurrently (default: 1).
|
|
158
|
+
* Set to a positive integer (e.g. `4`) or `Infinity` to run independent DAG branches in parallel.
|
|
159
|
+
*/
|
|
160
|
+
concurrency?: number | undefined;
|
|
161
|
+
};
|
|
162
|
+
type OutputsOnSuccess<TSeeders extends readonly SeederAny[], TOptions> = [TOptions] extends [
|
|
163
|
+
undefined
|
|
164
|
+
] ? SeederOutputs<TSeeders> : TOptions extends {
|
|
165
|
+
readonly only: readonly (infer TOnly extends string)[];
|
|
166
|
+
} ? string extends TOnly ? Partial<SeederOutputs<TSeeders>> : Prettify<Pick<SeederOutputs<TSeeders>, Extract<TOnly, keyof SeederOutputs<TSeeders>>> & Partial<SeederOutputs<TSeeders>>> : TOptions extends {
|
|
167
|
+
readonly only?: readonly string[] | undefined;
|
|
168
|
+
} ? 'only' extends keyof TOptions ? Partial<SeederOutputs<TSeeders>> : SeederOutputs<TSeeders> : SeederOutputs<TSeeders>;
|
|
169
|
+
/** Return value of `runSeeders` with typed `results` and `outputs` */
|
|
170
|
+
export type RunSeedersResult<TSeeders extends readonly SeederAny[] = readonly SeederAny[], TOptions = undefined> = {
|
|
171
|
+
success: true;
|
|
172
|
+
results: SeederResultFor<TSeeders>[];
|
|
173
|
+
outputs: OutputsOnSuccess<TSeeders, TOptions>;
|
|
174
|
+
} | {
|
|
175
|
+
success: false;
|
|
176
|
+
results: SeederResultFor<TSeeders>[];
|
|
177
|
+
outputs: Partial<SeederOutputs<TSeeders>>;
|
|
97
178
|
};
|
|
179
|
+
export {};
|
|
180
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC,4EAA4E;AAC5E,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,EAAE,CAAA;AAEvD,mDAAmD;AACnD,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;AAE5C,kCAAkC;AAClC,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAE5D,6DAA6D;AAC7D,MAAM,MAAM,SAAS,GAClB,aAAa,GACb,SAAS,SAAS,EAAE,GACpB;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;CAAE,CAAA;AAEpD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC/B,8CAA8C;IAC9C,KAAK,EAAE,KAAK,CAAA;IACZ,mDAAmD;IACnD,IAAI,EAAE,MAAM,CA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ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA"}
|
package/dist/state.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
// src/seeding-state.ts
|
|
2
2
|
var key = Symbol.for("plantr.seedingActive");
|
|
3
|
+
var countKey = Symbol.for("plantr.seedingCount");
|
|
3
4
|
var state = globalThis;
|
|
4
5
|
function isSeedingActive() {
|
|
5
6
|
return state[key] === true;
|
|
6
7
|
}
|
|
7
|
-
function
|
|
8
|
-
state[
|
|
8
|
+
function enterSeeding() {
|
|
9
|
+
const next = (state[countKey] ?? 0) + 1;
|
|
10
|
+
state[countKey] = next;
|
|
11
|
+
state[key] = true;
|
|
12
|
+
}
|
|
13
|
+
function exitSeeding() {
|
|
14
|
+
const next = Math.max(0, (state[countKey] ?? 0) - 1);
|
|
15
|
+
state[countKey] = next;
|
|
16
|
+
state[key] = next > 0;
|
|
9
17
|
}
|
|
10
18
|
export {
|
|
11
19
|
isSeedingActive
|
package/index.ts
CHANGED
|
@@ -9,15 +9,10 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```typescript
|
|
12
|
-
* import { createSeederInstance
|
|
12
|
+
* import { createSeederInstance } from 'plantr'
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* const { defineSeeder, runSeeders } = createSeederInstance<MyContext>({
|
|
17
|
-
* context: (base) => ({
|
|
18
|
-
* ...base,
|
|
19
|
-
* prisma,
|
|
20
|
-
* }),
|
|
14
|
+
* const { defineSeeder, runSeeders } = createSeederInstance({
|
|
15
|
+
* context: () => ({ prisma }),
|
|
21
16
|
* })
|
|
22
17
|
*
|
|
23
18
|
* const userSeeder = defineSeeder({
|
|
@@ -32,48 +27,86 @@
|
|
|
32
27
|
* }
|
|
33
28
|
* })
|
|
34
29
|
*
|
|
35
|
-
* await runSeeders([userSeeder])
|
|
30
|
+
* const run = await runSeeders([userSeeder])
|
|
31
|
+
* if (run.success) {
|
|
32
|
+
* console.log(run.outputs.userSeeder.userId)
|
|
33
|
+
* }
|
|
36
34
|
* ```
|
|
37
35
|
*/
|
|
38
36
|
|
|
39
|
-
// Re-export faker and expect for convenience
|
|
37
|
+
// Re-export lazy-loaded English faker (0ms until first access) and expect for convenience
|
|
40
38
|
export { expect } from 'bun:test'
|
|
41
|
-
export {
|
|
42
|
-
|
|
39
|
+
export type { Faker } from '@faker-js/faker'
|
|
40
|
+
// CLI types
|
|
41
|
+
export type { RunSeedersCliOptions } from './src/cli.js'
|
|
43
42
|
// Main API
|
|
44
|
-
export type {
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
export type {
|
|
44
|
+
ResolvedContext,
|
|
45
|
+
SeederInstance,
|
|
46
|
+
SeederInstanceConfig,
|
|
47
|
+
} from './src/create-seeder-instance.js'
|
|
48
|
+
export { createSeederInstance } from './src/create-seeder-instance.js'
|
|
47
49
|
// Utilities (for advanced use cases)
|
|
48
|
-
export { createDefineSeeder } from './src/define-seeder'
|
|
50
|
+
export { createDefineSeeder } from './src/define-seeder.js'
|
|
49
51
|
export {
|
|
50
52
|
CircularDependencyError,
|
|
51
53
|
DuplicateSeederError,
|
|
52
54
|
MissingDependencyError,
|
|
53
55
|
resolveDependencyOrder,
|
|
54
56
|
UnknownSeederError,
|
|
55
|
-
} from './src/dependency-resolver'
|
|
56
|
-
export {
|
|
57
|
-
export {
|
|
57
|
+
} from './src/dependency-resolver.js'
|
|
58
|
+
export type { ColorName, StyleName } from './src/formatting.js'
|
|
59
|
+
export { colorize, formatDuration } from './src/formatting.js'
|
|
60
|
+
export { lazyFaker as faker } from './src/lazy-faker.js'
|
|
61
|
+
export type {
|
|
62
|
+
InternalSeederConfig,
|
|
63
|
+
SeederScopeHandle,
|
|
64
|
+
TargetDescription,
|
|
65
|
+
} from './src/run-seeders.js'
|
|
66
|
+
export { describeTarget, runSeedersCore, SeedTargetError } from './src/run-seeders.js'
|
|
58
67
|
|
|
59
68
|
// Seeding state. Runtime code (job queues, mailers) should import it from 'plantr/state',
|
|
60
69
|
// which does not load faker or bun:test.
|
|
61
|
-
export { isSeedingActive } from './src/seeding-state'
|
|
70
|
+
export { isSeedingActive } from './src/seeding-state.js'
|
|
62
71
|
|
|
63
72
|
// Step types and cache
|
|
64
|
-
export type {
|
|
65
|
-
|
|
73
|
+
export type {
|
|
74
|
+
CacheEntry,
|
|
75
|
+
CacheWrite,
|
|
76
|
+
SeederCache,
|
|
77
|
+
StepFn,
|
|
78
|
+
StepOptions,
|
|
79
|
+
StepRecord,
|
|
80
|
+
StepRunner,
|
|
81
|
+
StepRunnerConfig,
|
|
82
|
+
StepScope,
|
|
83
|
+
} from './src/step.js'
|
|
84
|
+
export { createStepRunner } from './src/step.js'
|
|
66
85
|
|
|
67
86
|
// Types
|
|
68
87
|
export type {
|
|
69
88
|
BaseSeederContext,
|
|
89
|
+
CompletedSeederResult,
|
|
70
90
|
DepsFromSeeders,
|
|
91
|
+
FailedSeederResult,
|
|
92
|
+
JsonPrimitive,
|
|
93
|
+
JsonValue,
|
|
94
|
+
MaybePromise,
|
|
95
|
+
MissingSeederDeps,
|
|
96
|
+
PendingSeederResult,
|
|
97
|
+
Prettify,
|
|
71
98
|
RunSeedersOptions,
|
|
99
|
+
RunSeedersResult,
|
|
72
100
|
Seeder,
|
|
73
101
|
SeederAny,
|
|
74
102
|
SeederConfig,
|
|
103
|
+
SeederDeps,
|
|
75
104
|
SeederName,
|
|
76
105
|
SeederOutput,
|
|
106
|
+
SeederOutputs,
|
|
77
107
|
SeederResult,
|
|
108
|
+
SeederResultFor,
|
|
78
109
|
SeederStatus,
|
|
79
|
-
|
|
110
|
+
SkippedSeederResult,
|
|
111
|
+
ValidateSeeders,
|
|
112
|
+
} from './src/types.js'
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plantr",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A generic seeder library with built-in faker, step, and expect support for type-safe database seeding",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
6
7
|
"module": "./dist/index.js",
|
|
7
8
|
"main": "./dist/index.js",
|
|
8
9
|
"types": "./dist/index.d.ts",
|