@stripe/extensibility-tool-utils 0.6.2

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 (105) hide show
  1. package/LICENSE.md +19 -0
  2. package/dist/cli/cli-ux.d.ts +30 -0
  3. package/dist/cli/cli-ux.d.ts.map +1 -0
  4. package/dist/cli/context.d.ts +24 -0
  5. package/dist/cli/context.d.ts.map +1 -0
  6. package/dist/cli/guards.d.ts +24 -0
  7. package/dist/cli/guards.d.ts.map +1 -0
  8. package/dist/cli/index.d.ts +6 -0
  9. package/dist/cli/index.d.ts.map +1 -0
  10. package/dist/cli/output-path.d.ts +11 -0
  11. package/dist/cli/output-path.d.ts.map +1 -0
  12. package/dist/extensibility-tool-utils-alpha.d.ts +383 -0
  13. package/dist/extensibility-tool-utils-beta.d.ts +383 -0
  14. package/dist/extensibility-tool-utils-internal.d.ts +1866 -0
  15. package/dist/extensibility-tool-utils-public.d.ts +383 -0
  16. package/dist/file-editor/assertions/index.d.ts +68 -0
  17. package/dist/file-editor/assertions/index.d.ts.map +1 -0
  18. package/dist/file-editor/document.d.ts +107 -0
  19. package/dist/file-editor/document.d.ts.map +1 -0
  20. package/dist/file-editor/errors.d.ts +66 -0
  21. package/dist/file-editor/errors.d.ts.map +1 -0
  22. package/dist/file-editor/facades/api-extractor.d.ts +34 -0
  23. package/dist/file-editor/facades/api-extractor.d.ts.map +1 -0
  24. package/dist/file-editor/facades/brands.d.ts +45 -0
  25. package/dist/file-editor/facades/brands.d.ts.map +1 -0
  26. package/dist/file-editor/facades/package-json.d.ts +55 -0
  27. package/dist/file-editor/facades/package-json.d.ts.map +1 -0
  28. package/dist/file-editor/facades/stripe-app-manifest.d.ts +62 -0
  29. package/dist/file-editor/facades/stripe-app-manifest.d.ts.map +1 -0
  30. package/dist/file-editor/facades/tsconfig-options.d.ts +76 -0
  31. package/dist/file-editor/facades/tsconfig-options.d.ts.map +1 -0
  32. package/dist/file-editor/facades/tsconfig.d.ts +43 -0
  33. package/dist/file-editor/facades/tsconfig.d.ts.map +1 -0
  34. package/dist/file-editor/fingerprint.d.ts +39 -0
  35. package/dist/file-editor/fingerprint.d.ts.map +1 -0
  36. package/dist/file-editor/formats/adapter.d.ts +29 -0
  37. package/dist/file-editor/formats/adapter.d.ts.map +1 -0
  38. package/dist/file-editor/formats/detect.d.ts +9 -0
  39. package/dist/file-editor/formats/detect.d.ts.map +1 -0
  40. package/dist/file-editor/formats/index.d.ts +13 -0
  41. package/dist/file-editor/formats/index.d.ts.map +1 -0
  42. package/dist/file-editor/formats/jsonc.d.ts +14 -0
  43. package/dist/file-editor/formats/jsonc.d.ts.map +1 -0
  44. package/dist/file-editor/formats/yaml.d.ts +11 -0
  45. package/dist/file-editor/formats/yaml.d.ts.map +1 -0
  46. package/dist/file-editor/index.d.ts +42 -0
  47. package/dist/file-editor/index.d.ts.map +1 -0
  48. package/dist/file-editor/pointer.d.ts +74 -0
  49. package/dist/file-editor/pointer.d.ts.map +1 -0
  50. package/dist/file-editor/schema.d.ts +72 -0
  51. package/dist/file-editor/schema.d.ts.map +1 -0
  52. package/dist/file-editor/state/fs-manifest.d.ts +30 -0
  53. package/dist/file-editor/state/fs-manifest.d.ts.map +1 -0
  54. package/dist/file-editor/state/in-memory.d.ts +5 -0
  55. package/dist/file-editor/state/in-memory.d.ts.map +1 -0
  56. package/dist/file-editor/state/store.d.ts +19 -0
  57. package/dist/file-editor/state/store.d.ts.map +1 -0
  58. package/dist/file-editor/transaction.d.ts +60 -0
  59. package/dist/file-editor/transaction.d.ts.map +1 -0
  60. package/dist/file-editor/types.d.ts +131 -0
  61. package/dist/file-editor/types.d.ts.map +1 -0
  62. package/dist/file-editor/util/atomic-write.d.ts +7 -0
  63. package/dist/file-editor/util/atomic-write.d.ts.map +1 -0
  64. package/dist/file-editor/util/diff.d.ts +20 -0
  65. package/dist/file-editor/util/diff.d.ts.map +1 -0
  66. package/dist/file-editor/value-at-pointer.d.ts +46 -0
  67. package/dist/file-editor/value-at-pointer.d.ts.map +1 -0
  68. package/dist/index.cjs +2967 -0
  69. package/dist/index.d.ts +26 -0
  70. package/dist/index.d.ts.map +1 -0
  71. package/dist/index.js +2847 -0
  72. package/dist/logging/create-logger.d.ts +29 -0
  73. package/dist/logging/create-logger.d.ts.map +1 -0
  74. package/dist/logging/index.d.ts +10 -0
  75. package/dist/logging/index.d.ts.map +1 -0
  76. package/dist/logging/levels.d.ts +21 -0
  77. package/dist/logging/levels.d.ts.map +1 -0
  78. package/dist/naming/inflection.d.ts +15 -0
  79. package/dist/naming/inflection.d.ts.map +1 -0
  80. package/dist/naming/metadata-policy.d.ts +35 -0
  81. package/dist/naming/metadata-policy.d.ts.map +1 -0
  82. package/dist/naming/stripe-api-case.d.ts +9 -0
  83. package/dist/naming/stripe-api-case.d.ts.map +1 -0
  84. package/dist/naming/types.d.ts +11 -0
  85. package/dist/naming/types.d.ts.map +1 -0
  86. package/dist/naming/validate.d.ts +6 -0
  87. package/dist/naming/validate.d.ts.map +1 -0
  88. package/dist/templates/filesystem-fs.d.ts +20 -0
  89. package/dist/templates/filesystem-fs.d.ts.map +1 -0
  90. package/dist/templates/generator.d.ts +305 -0
  91. package/dist/templates/generator.d.ts.map +1 -0
  92. package/dist/templates/in-memory-fs.d.ts +44 -0
  93. package/dist/templates/in-memory-fs.d.ts.map +1 -0
  94. package/dist/templates/index.d.ts +28 -0
  95. package/dist/templates/index.d.ts.map +1 -0
  96. package/dist/templates/simple-templates.d.ts +75 -0
  97. package/dist/templates/simple-templates.d.ts.map +1 -0
  98. package/dist/templates/template-manager.d.ts +54 -0
  99. package/dist/templates/template-manager.d.ts.map +1 -0
  100. package/dist/templates/types.d.ts +87 -0
  101. package/dist/templates/types.d.ts.map +1 -0
  102. package/dist/tsconfig.build.tsbuildinfo +1 -0
  103. package/dist/workspace-versions.d.ts +30 -0
  104. package/dist/workspace-versions.d.ts.map +1 -0
  105. package/package.json +60 -0
@@ -0,0 +1,1866 @@
1
+ /**
2
+ * `@stripe/extensibility-tool-utils`
3
+ *
4
+ * Internal standalone utilities shared across Stripe extensibility tooling.
5
+ *
6
+ * @packageDocumentation
7
+ * @internal
8
+ */
9
+
10
+ import type { MetadataInferenceContext } from '@formspec/core';
11
+ import type { MetadataPolicyInput } from '@formspec/core';
12
+ import pino from 'pino';
13
+
14
+ /**
15
+ * Branded string types with validating smart constructors.
16
+ *
17
+ * Brands use symbol keys so they do not appear in IDE autocomplete
18
+ * (per project convention).
19
+ */
20
+ declare const __semverRangeBrand: unique symbol;
21
+
22
+ /** A well-formed semver version string (e.g. `"1.2.3"`, `"4.0.0-rc.1"`). */
23
+ declare const __semverVersionBrand: unique symbol;
24
+
25
+ /**
26
+ * Structured result returned by an `afterExecute` hook.
27
+ * @internal
28
+ */
29
+ export declare interface _AfterExecuteResult {
30
+ /** Descriptions of side effects that were performed. */
31
+ readonly sideEffects?: readonly string[];
32
+ }
33
+
34
+ /** @internal */
35
+ export declare interface _ApiExtractorConfig {
36
+ readonly projectFolder?: string;
37
+ readonly mainEntryPointFilePath?: string;
38
+ readonly apiReport?: {
39
+ readonly enabled?: boolean;
40
+ readonly reportFileName?: string;
41
+ readonly reportFolder?: string;
42
+ };
43
+ readonly dtsRollup?: {
44
+ readonly enabled?: boolean;
45
+ readonly publicTrimmedFilePath?: string;
46
+ readonly untrimmedFilePath?: string;
47
+ };
48
+ }
49
+
50
+ /** @internal */
51
+ export declare class _ApiExtractorDoc extends _Document<_ApiExtractorConfig> {
52
+ setMainEntryPoint(path: string, opts?: _MutationOptions<_ApiExtractorConfig>): this;
53
+ enableApiReport(folder: string, fileName: string, opts?: _MutationOptions<_ApiExtractorConfig>): this;
54
+ enableDtsRollup(publicPath: string, opts?: _MutationOptions<_ApiExtractorConfig>): this;
55
+ }
56
+
57
+ /**
58
+ * Validation result for an inferred or explicit name.
59
+ * @internal
60
+ */
61
+ export declare interface _ApiNameValidationResult {
62
+ /** Whether the name passes all validation rules. */
63
+ valid: boolean;
64
+ /** Human-readable messages describing each validation failure. */
65
+ reasons: string[];
66
+ }
67
+
68
+ /** A read-only predicate over a document-shaped value. @internal */
69
+ export declare type _Assertion = (ctx: _AssertionContext) => _Diagnostic[];
70
+
71
+ /** Context handed to each assertion. @internal */
72
+ export declare interface _AssertionContext {
73
+ readonly path: string;
74
+ readonly value: unknown;
75
+ }
76
+
77
+ /** A required value failed an assertion check. */
78
+ /** @internal */
79
+ export declare class _AssertionError extends _FileEditorError {
80
+ readonly pointer: _JsonPointer;
81
+ readonly expected: unknown;
82
+ readonly actual: unknown;
83
+ constructor(pointer: _JsonPointer, message: string, details?: {
84
+ actual?: unknown;
85
+ expected?: unknown;
86
+ });
87
+ }
88
+
89
+ /** @internal */
90
+ export declare interface _AssertOpts {
91
+ readonly severity?: _Severity;
92
+ readonly message?: string;
93
+ }
94
+
95
+ /** An assertion that defers to an async validator (e.g. a Standard Schema). @internal */
96
+ export declare type _AsyncAssertion = (ctx: _AssertionContext) => Promise<_Diagnostic[]>;
97
+
98
+ /**
99
+ * Structured result returned by a `beforeExecute` hook.
100
+ *
101
+ * Returning `{ proceed: false, reason: '...', remediation: '...' }` is a
102
+ * normal rejection — the user should fix their input. Throwing indicates a
103
+ * generator defect and should be filed as a bug.
104
+ *
105
+ * The discriminated union enforces that `reason` is always present when
106
+ * `proceed` is `false` — `{ proceed: false }` without a reason is a type error.
107
+ * @internal
108
+ */
109
+ export declare type _BeforeExecuteResult = {
110
+ readonly proceed: false;
111
+ readonly reason: string;
112
+ readonly remediation?: string;
113
+ } | { readonly proceed: true };
114
+
115
+ /** Begin a new transaction. */
116
+ /** @internal */
117
+ export declare function _beginTransaction(options?: _TransactionOptions): _Transaction;
118
+
119
+ /**
120
+ * Produce a canonical, deterministic string form of the document's *semantic*
121
+ * content. Two documents with identical semantics produce identical canonical
122
+ * strings regardless of formatting or comments.
123
+ */
124
+ /** @internal */
125
+ export declare function _canonicalNormalize(text: string, format: _Format): string;
126
+
127
+ /**
128
+ * Deterministic stringification of a plain-JSON value.
129
+ *
130
+ * Rules:
131
+ * - Object keys sorted ascending by UTF-16 code unit.
132
+ * - Strings Unicode NFC-normalized and emitted as JSON strings.
133
+ * - Numbers: finite → canonical form (JSON.stringify); NaN/Infinity reject.
134
+ * - Arrays preserve element order (order is semantic).
135
+ * - `undefined` anywhere in an object drops the key (matches JSON semantics);
136
+ * inside an array it serializes as `null`.
137
+ */
138
+ /** @internal */
139
+ export declare function _canonicalStringify(value: unknown): string;
140
+
141
+ /**
142
+ * Read-only predicate factories that produce {@link _Assertion}s and
143
+ * {@link _AsyncAssertion}s. Compose via {@link _Document.assert}.
144
+ * @internal
145
+ */
146
+ export declare const _check: {
147
+ readonly equals: (pointer: _JsonPointer, expected: unknown, opts?: _AssertOpts) => _Assertion;
148
+ readonly exists: (pointer: _JsonPointer, opts?: _AssertOpts) => _Assertion;
149
+ readonly matches: (pointer: _JsonPointer, pattern: RegExp, opts?: _AssertOpts) => _Assertion;
150
+ readonly matchesSchema: (pointer: _JsonPointer, schema: _StandardSchemaV1, opts?: _AssertOpts) => _AsyncAssertion;
151
+ readonly oneOf: (pointer: _JsonPointer, allowed: readonly unknown[], opts?: _AssertOpts) => _Assertion;
152
+ readonly satisfies: (pointer: _JsonPointer, predicate: (v: unknown) => boolean, opts?: _AssertOpts) => _Assertion;
153
+ readonly semverSatisfies: (pointer: _JsonPointer, range: string, opts?: _AssertOpts) => _Assertion;
154
+ };
155
+
156
+ /**
157
+ * Shared context threaded through CLI operations.
158
+ *
159
+ * Carry this through call chains so that output can be redirected in tests
160
+ * without patching global `process.stdout`/`process.stderr`.
161
+ *
162
+ * @internal
163
+ */
164
+ export declare interface _CliContext {
165
+ /** Output abstraction for writing to stdout/stderr. */
166
+ readonly ux: _CliUx;
167
+ }
168
+
169
+ /**
170
+ * Thin output abstraction used by CLI entry points and the functions they call.
171
+ *
172
+ * Inject a `_CliUx` constructed with `PassThrough` streams in tests to capture
173
+ * output without spying on `process.stdout`/`process.stderr`.
174
+ *
175
+ * @internal
176
+ */
177
+ export declare class _CliUx {
178
+ #private;
179
+ constructor(options?: {
180
+ readonly stderr?: NodeJS.WritableStream;
181
+ readonly stdout?: NodeJS.WritableStream;
182
+ });
183
+ /** Write a product output line to stdout (or the configured stream). */
184
+ print(message: string): void;
185
+ /** Write a status/progress line to stderr (or the configured stream). */
186
+ log(message: string): void;
187
+ /**
188
+ * Error message to **stderr** (or the configured stderr stream).
189
+ *
190
+ * Behaviorally identical to {@link _CliUx.log} today. Use `error()` for failures
191
+ * and `log()` for progress/status — the distinction supports future
192
+ * formatting differentiation (color, prefixes, severity filtering).
193
+ */
194
+ error(message: string): void;
195
+ }
196
+
197
+ /** Options supplied at {@link _Transaction.commit} time. */
198
+ /** @internal */
199
+ export declare interface _CommitOptions {
200
+ readonly defaultPolicy?: _ConflictPolicy;
201
+ }
202
+
203
+ /** Full report of a (dry-run or actual) commit. */
204
+ /** @internal */
205
+ export declare interface _CommitReport {
206
+ readonly written: readonly {
207
+ readonly bytesAfter: number;
208
+ readonly bytesBefore: number;
209
+ readonly path: string;
210
+ readonly unifiedDiff: string;
211
+ }[];
212
+ readonly skipped: readonly {
213
+ readonly path: string;
214
+ readonly reason: 'conflict-skipped' | 'no-change' | 'schema-invalid' | 'write-skipped';
215
+ }[];
216
+ readonly conflicts: readonly _Conflict[];
217
+ readonly diagnostics: readonly _Diagnostic[];
218
+ }
219
+
220
+ /** Compile an array of raw (unescaped) tokens into a JSON Pointer string. */
221
+ /** @internal */
222
+ export declare function _compilePointer(segments: readonly (number | string)[]): _JsonPointer;
223
+
224
+ /**
225
+ * Key of {@link _CompilerOptions}. Method signatures use
226
+ * `<K extends _CompilerOptionKey>(name: K, value: _CompilerOptions[K])`
227
+ * so the value type is narrowed by the key.
228
+ */
229
+ /** @internal */
230
+ export declare type _CompilerOptionKey = keyof _CompilerOptions;
231
+
232
+ /** Typed subset of `compilerOptions`. Unknown keys can still be set via the generic API. */
233
+ /** @internal */
234
+ export declare interface _CompilerOptions {
235
+ readonly target?: _TsTarget;
236
+ readonly module?: _TsModule;
237
+ readonly moduleResolution?: _TsModuleResolution;
238
+ readonly lib?: readonly string[];
239
+ readonly types?: readonly string[];
240
+ readonly jsx?: _TsJsx;
241
+ readonly jsxImportSource?: string;
242
+ readonly strict?: boolean;
243
+ readonly noImplicitAny?: boolean;
244
+ readonly strictNullChecks?: boolean;
245
+ readonly strictFunctionTypes?: boolean;
246
+ readonly strictBindCallApply?: boolean;
247
+ readonly strictPropertyInitialization?: boolean;
248
+ readonly alwaysStrict?: boolean;
249
+ readonly noImplicitThis?: boolean;
250
+ readonly noUncheckedIndexedAccess?: boolean;
251
+ readonly noImplicitOverride?: boolean;
252
+ readonly noPropertyAccessFromIndexSignature?: boolean;
253
+ readonly exactOptionalPropertyTypes?: boolean;
254
+ readonly noFallthroughCasesInSwitch?: boolean;
255
+ readonly noImplicitReturns?: boolean;
256
+ readonly noUnusedLocals?: boolean;
257
+ readonly noUnusedParameters?: boolean;
258
+ readonly useUnknownInCatchVariables?: boolean;
259
+ readonly outDir?: string;
260
+ readonly rootDir?: string;
261
+ readonly declaration?: boolean;
262
+ readonly declarationMap?: boolean;
263
+ readonly declarationDir?: string;
264
+ readonly sourceMap?: boolean;
265
+ readonly inlineSources?: boolean;
266
+ readonly noEmit?: boolean;
267
+ readonly noEmitOnError?: boolean;
268
+ readonly removeComments?: boolean;
269
+ readonly importHelpers?: boolean;
270
+ readonly downlevelIteration?: boolean;
271
+ readonly esModuleInterop?: boolean;
272
+ readonly allowSyntheticDefaultImports?: boolean;
273
+ readonly forceConsistentCasingInFileNames?: boolean;
274
+ readonly isolatedModules?: boolean;
275
+ readonly verbatimModuleSyntax?: boolean;
276
+ readonly resolveJsonModule?: boolean;
277
+ readonly skipLibCheck?: boolean;
278
+ readonly baseUrl?: string;
279
+ readonly paths?: Readonly<Record<string, readonly string[]>>;
280
+ readonly composite?: boolean;
281
+ readonly incremental?: boolean;
282
+ readonly tsBuildInfoFile?: string;
283
+ }
284
+
285
+ /** Defined (non-undefined) value type at a given key. */
286
+ /** @internal */
287
+ export declare type _CompilerOptionValue<K extends _CompilerOptionKey> = NonNullable<_CompilerOptions[K]>;
288
+
289
+ /**
290
+ * Compose multiple generators with the same params into a single runner.
291
+ *
292
+ * The composite runner merges all file outputs and runs all lifecycle hooks
293
+ * in declaration order.
294
+ *
295
+ * @typeParam TParams - Shared user-provided parameters type
296
+ * @internal
297
+ */
298
+ export declare function _compositeGenerator<TParams extends object>(...generators: ReadonlyArray<_Generator<TParams>>): _GeneratorRunner<TParams>;
299
+
300
+ /** When the `confirmWrite` hook should be invoked. */
301
+ /** @internal */
302
+ export declare type _ConfirmationPolicy = 'always' | 'never' | 'on-conflict';
303
+
304
+ /** Describes a detected drift event. */
305
+ /** @internal */
306
+ export declare interface _Conflict {
307
+ readonly path: string;
308
+ /** Text the library intended to write. */
309
+ readonly ours: string;
310
+ /** Current on-disk text. */
311
+ readonly theirs: string;
312
+ /** Text at last recorded write, if retained. */
313
+ readonly base: null | string;
314
+ readonly lastWriteAt: null | string;
315
+ readonly lastWriteTool: null | string;
316
+ }
317
+
318
+ /** Resolver or confirmWrite returned "abort". */
319
+ /** @internal */
320
+ export declare class _ConflictAbortedError extends _FileEditorError {
321
+ readonly path: string;
322
+ constructor(path: string);
323
+ }
324
+
325
+ /** Drift detected and policy was "error". */
326
+ /** @internal */
327
+ export declare class _ConflictError extends _FileEditorError {
328
+ readonly conflict: _Conflict;
329
+ constructor(conflict: _Conflict);
330
+ }
331
+
332
+ /** Policy for handling on-disk drift at commit time. */
333
+ /** @internal */
334
+ export declare type _ConflictPolicy = 'ask' | 'error' | 'overwrite' | 'skip';
335
+
336
+ /** Result of resolving a conflict. */
337
+ /** @internal */
338
+ export declare type _ConflictResolution = 'abort' | 'overwrite' | 'skip';
339
+
340
+ /** @internal */
341
+ export declare type _ConflictResolver = (c: _Conflict) => Promise<_ConflictResolution>;
342
+
343
+ /**
344
+ * Create a `_CliContext` with default or injected collaborators.
345
+ *
346
+ * @param options - Optional options. Pass a pre-constructed `_CliUx` to redirect output
347
+ * streams (e.g., for testing or RPC transports that must not write to stdout).
348
+ * @internal
349
+ */
350
+ export declare function _createCliContext(options?: { ux?: _CliUx }): _CliContext;
351
+
352
+ /**
353
+ * Create a TemplateFS instance rooted at the given directory.
354
+ *
355
+ * Each Mustache render call passes a per-call escape config so that no global
356
+ * Mustache state is mutated. Because we generate source code (not HTML), HTML
357
+ * escaping is intentionally disabled.
358
+ *
359
+ * @param templateDir - Root directory. Defaults to `process.cwd()`.
360
+ * @internal
361
+ */
362
+ export declare function _createFilesystemTemplateFS(templateDir?: string): _TemplateFS;
363
+
364
+ /**
365
+ * Create an in-memory TemplateFS instance
366
+ *
367
+ * Caller must provide exact paths including any base path prefix.
368
+ * For example, to read "extensions/common/tsconfig.json", pass:
369
+ * fs.textFile('extensions', 'common', 'tsconfig.json')
370
+ *
371
+ * Or use scope() to create a scoped instance:
372
+ * fs.scope('extensions').textFile('common', 'tsconfig.json')
373
+ *
374
+ * @param image - Array of template entries with path and content
375
+ * @param pathPrefix - Optional path prefix to prepend to all operations
376
+ * @returns TemplateFS instance that reads from in-memory image
377
+ * @internal
378
+ */
379
+ export declare function _createInMemoryTemplateFS(image: _TemplateFSImageEntry[], pathPrefix?: string): _InMemoryTemplateFS;
380
+
381
+ /**
382
+ * Creates a pino logger that writes to stderr with colorized pretty-print output.
383
+ * Stderr is used so that structured log lines do not pollute stdout-based CLI output.
384
+ *
385
+ * @param options - Optional name and level overrides.
386
+ * @returns A configured pino Logger instance.
387
+ *
388
+ * @internal
389
+ */
390
+ export declare function _createLogger(options?: _LoggerOptions): pino.Logger;
391
+
392
+ /**
393
+ * Helper for creating a SingleTemplateManager with simple single-file generation
394
+ *
395
+ * @param generateContent - Function that generates file content from parameters
396
+ * @param pathTemplate - Function that generates file path from parameters
397
+ * @returns SingleTemplateManager ready to use
398
+ *
399
+ * @example
400
+ * ```typescript
401
+ * interface MyParams {
402
+ * name: string
403
+ * }
404
+ *
405
+ * // Simple template that generates content from parameters
406
+ * const templateManager = createSimpleSingleFileTemplate<MyParams>(
407
+ * (params) => `export class ${params.name} { ... }`,
408
+ * (params) => `src/${snakeCase(params.name)}.ts`
409
+ * )
410
+ *
411
+ * const output = await templateManager.generate({ name: 'MyClass' })
412
+ * // output.files[0] = { path: 'src/my_class.ts', content: '...' }
413
+ * ```
414
+ * @internal
415
+ */
416
+ export declare function _createSimpleSingleFileTemplate<TParams>(generateContent: (params: TParams) => string, pathTemplate: (params: TParams) => string): _SingleTemplateManager<TParams>;
417
+
418
+ /**
419
+ * Convert a simple content generator to a full Template
420
+ * @param generateContent - Function that generates file content from parameters
421
+ * @param pathTemplate - Function that generates file path from parameters
422
+ * @returns Full Template implementation
423
+ *
424
+ * @example
425
+ * ```typescript
426
+ * interface MyParams {
427
+ * name: string
428
+ * version: string
429
+ * }
430
+ *
431
+ * const template = createSimpleTemplate<MyParams>(
432
+ * (params) => `export const ${params.name} = "${params.version}";`,
433
+ * (params) => `src/${snakeCase(params.name)}.ts`
434
+ * )
435
+ * ```
436
+ * @internal
437
+ */
438
+ export declare function _createSimpleTemplate<TParams>(generateContent: (params: TParams) => string, pathTemplate: (params: TParams) => string): _Template<TParams>;
439
+
440
+ /** Default format metadata used when no source text exists yet. */
441
+ /** @internal */
442
+ export declare function _defaultMeta(): _FormatMeta;
443
+
444
+ /** @internal */
445
+ export declare type _DepKind = 'dependencies' | 'devDependencies' | 'optionalDependencies' | 'peerDependencies';
446
+
447
+ /**
448
+ * Infer a {@link _Format} for a path, optionally using the file's text to
449
+ * disambiguate. Falls back to a {@link _FormatNotSupportedError} if no
450
+ * reasonable inference is possible.
451
+ */
452
+ /** @internal */
453
+ export declare function _detectFormat(path: string, text?: string): _Format;
454
+
455
+ /** Detect indentation, EOL style, BOM, and final-newline from source text. */
456
+ /** @internal */
457
+ export declare function _detectMeta(text: string): _FormatMeta;
458
+
459
+ /** A single finding produced by an assertion or commit flow. */
460
+ /** @internal */
461
+ export declare interface _Diagnostic {
462
+ readonly path: string;
463
+ readonly pointer: _JsonPointer;
464
+ readonly code: string;
465
+ readonly severity: _Severity;
466
+ readonly message: string;
467
+ readonly expected?: unknown;
468
+ readonly actual?: unknown;
469
+ }
470
+
471
+ /** Structured representation of a unified-diff hunk. */
472
+ /** @internal */
473
+ export declare interface _DiffHunk {
474
+ readonly oldStart: number;
475
+ readonly oldLines: number;
476
+ readonly newStart: number;
477
+ readonly newLines: number;
478
+ readonly lines: readonly _DiffLine[];
479
+ }
480
+
481
+ /** Produce structured diff _hunks (for custom TUI rendering). */
482
+ /** @internal */
483
+ export declare function _diffHunks(a: string, b: string, opts?: _DiffOptions): _DiffHunk[];
484
+
485
+ /** A single diff line within a hunk. */
486
+ /** @internal */
487
+ export declare interface _DiffLine {
488
+ readonly kind: 'add' | 'context' | 'del';
489
+ readonly text: string;
490
+ readonly oldLineNo: null | number;
491
+ readonly newLineNo: null | number;
492
+ }
493
+
494
+ /** @internal */
495
+ export declare interface _DiffOptions {
496
+ /** Number of context lines to include around each hunk. Default: 3. */
497
+ readonly context?: number;
498
+ readonly fileNameA?: string;
499
+ readonly fileNameB?: string;
500
+ }
501
+
502
+ /** Produce a _unified-diff string (`--- a / +++ b` headers and `@@` _hunks). */
503
+ /** @internal */
504
+ export declare function _diffUnified(a: string, b: string, opts?: _DiffOptions): string;
505
+
506
+ /**
507
+ * A parsed, editable document. Mutations are staged in memory and applied to
508
+ * the source text on demand (see {@link _Document.preview}).
509
+ *
510
+ * `T` is the *expected* shape of the document's root value. When `T` is
511
+ * `unknown` (the default), mutation signatures collapse to accept any value,
512
+ * so the class is usable schema-free. When `T` is a concrete interface,
513
+ * `get`/`set`/`addIfMissing`/etc. narrow both the pointer and the value
514
+ * type via {@link _ValueAtPointer}.
515
+ */
516
+ /** @internal */
517
+ export declare class _Document<T = unknown> {
518
+ readonly absolutePath: string;
519
+ readonly format: _Format;
520
+ /** Optional Standard Schema; when set, {@link _Document.validate} runs it. */
521
+ readonly schema: _StandardSchemaV1<T> | null;
522
+ /** Original on-disk text (may be `""` for new files). */
523
+ private readonly originalText;
524
+ private readonly meta;
525
+ private readonly edits;
526
+ private readonly staticDiagnostics;
527
+ constructor(init: {
528
+ readonly absolutePath: string;
529
+ readonly format: _Format;
530
+ readonly meta: _FormatMeta;
531
+ readonly originalText: string;
532
+ readonly schema?: _StandardSchemaV1<T> | null;
533
+ });
534
+ /** Get the value at a pointer. Reflects pending edits via `preview()`. */
535
+ get<P extends _JsonPointer>(pointer: P): _NarrowedValue<T, P> | undefined;
536
+ /** Like `get` but throws {@link _AssertionError} on miss. */
537
+ getRequired<P extends _JsonPointer>(pointer: P): _NarrowedValue<T, P>;
538
+ has(pointer: _JsonPointer): boolean;
539
+ set<P extends _JsonPointer>(pointer: P, value: _NarrowedValue<T, P>, opts?: _MutationOptions<T>): this;
540
+ addIfMissing<P extends _JsonPointer>(pointer: P, value: _NarrowedValue<T, P>, opts?: _MutationOptions<T>): this;
541
+ updateIfPresent<P extends _JsonPointer>(pointer: P, updater: (current: _NarrowedValue<T, P>) => _NarrowedValue<T, P>, opts?: _MutationOptions<T>): this;
542
+ remove(pointer: _JsonPointer, opts?: _MutationOptions<T>): this;
543
+ merge<P extends _JsonPointer>(pointer: P, partial: _NarrowedPartial<T, P>, opts?: _MutationOptions<T> & { mergeOptions?: _MergeOptions }): this;
544
+ arrayAppend<P extends _JsonPointer>(pointer: P, value: _NarrowedElement<T, P>, opts?: _MutationOptions<T>): this;
545
+ arrayUpsert<P extends _JsonPointer, E = _NarrowedElement<T, P>>(pointer: P, value: E, keyFn: (el: E) => unknown, opts?: _MutationOptions<T>): this;
546
+ assert(...checks: readonly _Assertion[]): _Diagnostic[];
547
+ /**
548
+ * If a schema is configured, validate the current preview against it and
549
+ * return a diagnostic per issue. Returns `[]` when no schema is set or
550
+ * validation passes.
551
+ *
552
+ * Each call replaces any previously accumulated `SCHEMA_VIOLATION` diagnostics
553
+ * so that calling `validate()` multiple times does not duplicate findings.
554
+ */
555
+ validate(): Promise<_Diagnostic[]>;
556
+ diagnostics(): readonly _Diagnostic[];
557
+ pendingEdits(): readonly _PendingEdit[];
558
+ /** Serialize with all pending edits applied. Pure — no disk I/O. */
559
+ preview(): string;
560
+ /** Reset all pending edits. Used by transactions on rollback. */
561
+ rollback(): void;
562
+ /** @internal Metadata for transaction serialization. */
563
+ getMeta(): _FormatMeta;
564
+ /** @internal Original text, for transaction fingerprinting. */
565
+ getOriginalText(): string;
566
+ private parseCurrentValue;
567
+ private stage;
568
+ private opts;
569
+ }
570
+
571
+ /** Escape a raw string into its JSON Pointer reference-token form. */
572
+ /** @internal */
573
+ export declare function _escapeToken(raw: string): string;
574
+
575
+ /** Base class for all errors raised by this library. */
576
+ /** @internal */
577
+ export declare class _FileEditorError extends Error {
578
+ readonly code: string;
579
+ constructor(code: string, message: string);
580
+ }
581
+
582
+ /**
583
+ * Outcome of writing a single planned file to disk.
584
+ * @internal
585
+ */
586
+ export declare interface _FileWriteOutcome {
587
+ readonly path: string;
588
+ readonly decision: 'created' | 'identical' | 'overwritten' | 'skipped';
589
+ readonly proposedContent: string;
590
+ readonly previousContent?: string;
591
+ /**
592
+ * Present only when `decision` is `'skipped'` due to an error (not user choice).
593
+ * For permission errors, disk errors, etc. Not present on 'created', 'overwritten', or 'identical'.
594
+ */
595
+ readonly error?: _WriteError;
596
+ }
597
+
598
+ /** SHA-256 hex digest of the canonical-normalized form. */
599
+ /** @internal */
600
+ export declare function _fingerprint(text: string, format: _Format): string;
601
+
602
+ /**
603
+ * Shared types for the structured config editor.
604
+ *
605
+ * @see https://datatracker.ietf.org/doc/html/rfc6901 — JSON Pointer
606
+ */
607
+ /** Supported document formats. */
608
+ /** @internal */
609
+ export declare type _Format = 'json' | 'jsonc' | 'yaml';
610
+
611
+ /**
612
+ * A format adapter knows how to parse a textual document, apply pending edits
613
+ * to that text while preserving formatting, and compute a canonical form for
614
+ * fingerprinting.
615
+ */
616
+ /** @internal */
617
+ export declare interface _FormatAdapter {
618
+ readonly format: _Format;
619
+ readonly permitsComments: boolean;
620
+ /** Parse text; throws {@link _ParseError} on failure. */
621
+ parse(text: string): {
622
+ meta: _FormatMeta;
623
+ value: unknown;
624
+ };
625
+ /**
626
+ * Apply edits to the source text and return the updated text.
627
+ * Must preserve all formatting (indent/EOL/BOM/comments) except at the
628
+ * precise locations touched by each edit.
629
+ */
630
+ applyEdits(text: string, edits: readonly _PendingEdit[], meta: _FormatMeta): string;
631
+ }
632
+
633
+ /** Format-specific metadata discovered while parsing. */
634
+ /** @internal */
635
+ export declare interface _FormatMeta {
636
+ readonly indent: string;
637
+ readonly eol: '\n' | '\r\n';
638
+ readonly hasFinalNewline: boolean;
639
+ readonly hasBom: boolean;
640
+ }
641
+
642
+ /** Unknown file extension with no format override. */
643
+ /** @internal */
644
+ export declare class _FormatNotSupportedError extends _FileEditorError {
645
+ readonly path: string;
646
+ constructor(path: string, message?: string);
647
+ }
648
+
649
+ /** Filesystem-backed manifest store. Safe for concurrent reads; single-writer. */
650
+ /** @internal */
651
+ export declare function _FsCentralManifestStore(options?: _FsCentralManifestStoreOptions): _StateStore;
652
+
653
+ /** @internal */
654
+ export declare interface _FsCentralManifestStoreOptions {
655
+ /** Root directory under which relative keys are computed. Default: `process.cwd()`. */
656
+ readonly rootDir?: string;
657
+ /** Manifest filename relative to `rootDir`. Default: `.file-editor/state.json`. */
658
+ readonly filename?: string;
659
+ /**
660
+ * If true, the manifest retains the full text of each managed file as of
661
+ * its last write, enabling three-way diffing via `_Conflict.base`.
662
+ * Off by default to limit disk usage.
663
+ */
664
+ readonly keepBaseSnapshots?: boolean;
665
+ }
666
+
667
+ /**
668
+ * Core generic types for the template system
669
+ *
670
+ * This module provides the foundation for a flexible, type-safe template system
671
+ * that can be specialized for different use cases (extensions, custom objects, etc.)
672
+ */
673
+ /**
674
+ * Represents a single generated file
675
+ * @internal
676
+ */
677
+ export declare interface _GeneratedFile {
678
+ /**
679
+ * Path to the file relative to project root
680
+ * Example: "extensions/my-extension/src/index.ts"
681
+ */
682
+ path: string;
683
+ /**
684
+ * Content of the file
685
+ */
686
+ content: string;
687
+ /**
688
+ * Never overwrite this file, even if --force specified.
689
+ */
690
+ precious?: boolean;
691
+ }
692
+
693
+ /**
694
+ * A composable unit of code generation.
695
+ *
696
+ * A generator combines:
697
+ * - A `files/` directory tree of Mustache templates that mirrors the output structure
698
+ * - A `locals()` function that computes template variables from user params
699
+ * - Optional lifecycle hooks for side effects (manifest updates, config changes)
700
+ *
701
+ * @typeParam TParams - User-provided parameters for this generator
702
+ * @internal
703
+ */
704
+ export declare interface _Generator<TParams extends object> {
705
+ /**
706
+ * Compute template variables from user-provided params.
707
+ *
708
+ * The returned record serves as the variable scope for both:
709
+ * - `___token___` resolution in file/directory names (structural placement)
710
+ * - `{{token}}` Mustache rendering in .mustache file content
711
+ *
712
+ * Params are the raw user inputs. Locals are the transformed, computed
713
+ * fields derived from params (e.g., PascalCase, snake_case, pluralized
714
+ * forms, default values). All template surfaces consume from locals.
715
+ *
716
+ * Path tokens (`___token___`) must resolve to strings.
717
+ * Content tokens (`{{token}}`) may be any Mustache-compatible value.
718
+ */
719
+ locals(params: TParams): Record<string, unknown>;
720
+ /**
721
+ * Root directory of this generator (parent of the `files/` subdirectory).
722
+ * The runner will look for templates under `<filesDir>/files/`.
723
+ */
724
+ readonly filesDir: string;
725
+ /**
726
+ * Map of template-relative file paths to human-readable descriptions.
727
+ *
728
+ * Keys are the literal filename in the `files/` tree (with `___token___`
729
+ * intact, e.g., `'___objectName___.object.ts.mustache'`). Values may use
730
+ * Mustache `{{token}}` syntax and are rendered with the generator's locals.
731
+ *
732
+ * Example:
733
+ * ```typescript
734
+ * descriptions: {
735
+ * '___objectName___.object.ts.mustache': 'Defines the {{className}} custom object',
736
+ * }
737
+ * ```
738
+ */
739
+ readonly descriptions?: Readonly<Record<string, string>>;
740
+ /**
741
+ * Run before files are generated (e.g., validate preconditions).
742
+ *
743
+ * Return `{ proceed: false, reason: '...', remediation: '...' }` to reject
744
+ * execution with user-actionable guidance.
745
+ *
746
+ * **Throwing** indicates a generator defect, not a user input problem.
747
+ */
748
+ beforeExecute?(params: TParams, context: _GeneratorContext): Promise<_BeforeExecuteResult>;
749
+ /**
750
+ * Run after files are written (e.g., update manifest, install deps).
751
+ *
752
+ * Returns a structured description of side effects performed.
753
+ *
754
+ * Note: if `afterExecute` throws, files have already been written to disk.
755
+ * The error propagates to the caller. Callers should handle this as a
756
+ * partial-completion scenario.
757
+ */
758
+ afterExecute?(params: TParams, context: _GeneratorContext, writeResult: _GeneratorWriteResult): Promise<_AfterExecuteResult>;
759
+ /**
760
+ * Return descriptions of side effects that `afterExecute` would perform,
761
+ * parameterized by the current params. Used for dry-run output.
762
+ *
763
+ * Returns a promise so future generators can inspect the filesystem to
764
+ * produce accurate descriptions.
765
+ */
766
+ describeSideEffects?(params: TParams): Promise<readonly string[]>;
767
+ }
768
+
769
+ /**
770
+ * Discriminated union of the two generator context shapes.
771
+ * @internal
772
+ */
773
+ export declare type _GeneratorContext = _ProjectGeneratorContext | _StandaloneGeneratorContext;
774
+
775
+ /**
776
+ * Thrown when the generator itself is malformed.
777
+ *
778
+ * This indicates a bug in the generator implementation that should be filed
779
+ * and fixed by the generator author.
780
+ * @internal
781
+ */
782
+ export declare class _GeneratorDefectError extends Error {
783
+ readonly generatorId: string | undefined;
784
+ constructor(message: string, generatorId?: string, options?: ErrorOptions);
785
+ }
786
+
787
+ /**
788
+ * Discriminated union of the two execute context shapes.
789
+ * @internal
790
+ */
791
+ export declare type _GeneratorExecuteContext = _ProjectExecuteContext | _StandaloneExecuteContext;
792
+
793
+ /**
794
+ * Result returned by `_GeneratorRunner.execute()`.
795
+ * @internal
796
+ */
797
+ export declare interface _GeneratorExecuteResult {
798
+ /** Files that were planned (same as plan().files). */
799
+ readonly files: readonly _PlannedFile[];
800
+ /** Preflight results from all `beforeExecute` hooks. */
801
+ readonly preflightResults: readonly _BeforeExecuteResult[];
802
+ /** Descriptions of side effects declared by generators. */
803
+ readonly plannedSideEffects: readonly string[];
804
+ /** The write result from the caller's `writeFiles` callback. Absent (undefined)
805
+ * if a preflight check rejected execution. */
806
+ readonly writeResult: _GeneratorWriteResult | undefined;
807
+ /** Results from all `afterExecute` hooks. */
808
+ readonly afterExecuteResults: readonly _AfterExecuteResult[];
809
+ }
810
+
811
+ /**
812
+ * Thrown when user-provided input is invalid.
813
+ *
814
+ * Intended for use by generator hooks (e.g., `beforeExecute` validation)
815
+ * and consuming code (CLI error handling). The runner itself throws
816
+ * `_GeneratorDefectError` for structural issues.
817
+ *
818
+ * Callers should display the message and `remediation` to the user.
819
+ * @internal
820
+ */
821
+ export declare class _GeneratorInputError extends Error {
822
+ readonly remediation: string | undefined;
823
+ constructor(message: string, remediation?: string, options?: ErrorOptions);
824
+ }
825
+
826
+ /**
827
+ * Result of `_GeneratorRunner.plan()`.
828
+ * @internal
829
+ */
830
+ export declare interface _GeneratorPlanResult {
831
+ /** Files that would be generated. */
832
+ readonly files: readonly _PlannedFile[];
833
+ /** Preflight results from all `beforeExecute` hooks. */
834
+ readonly preflightResults: readonly _BeforeExecuteResult[];
835
+ /** Descriptions of side effects that `afterExecute` hooks would perform. */
836
+ readonly plannedSideEffects: readonly string[];
837
+ }
838
+
839
+ /**
840
+ * Executes a single `_Generator` (or composite of generators), producing file
841
+ * outputs and running lifecycle hooks.
842
+ *
843
+ * Does NOT write files to disk — that responsibility belongs to the caller.
844
+ *
845
+ * @typeParam TParams - User-provided parameters type
846
+ * @internal
847
+ */
848
+ export declare class _GeneratorRunner<TParams extends object> {
849
+ #private;
850
+ constructor(generator: _Generator<TParams> | ReadonlyArray<_Generator<TParams>>);
851
+ /**
852
+ * Plan phase — compute all files that would be generated, without writing
853
+ * anything to disk.
854
+ *
855
+ * Also runs `beforeExecute` hooks to collect preflight results, and
856
+ * `describeSideEffects` to surface planned side effects. Neither of these
857
+ * write anything or produce observable external effects during plan.
858
+ *
859
+ * Use this for dry runs, previews, and testing.
860
+ *
861
+ * Validates that all output paths are safe (no `..`, no leading `/`) and
862
+ * that no two generators produce the same output path.
863
+ *
864
+ * @param params - User-provided parameters for the generator
865
+ * @param context - Generator context (standalone or project). Passed to
866
+ * `beforeExecute` hooks. Callers must supply a real context — there is no
867
+ * synthetic plan-time sentinel. For dry-run calls outside of a project,
868
+ * use a standalone context with an appropriate `targetDir`.
869
+ */
870
+ plan(params: TParams, context: _GeneratorContext): Promise<_GeneratorPlanResult>;
871
+ /**
872
+ * Execute phase — runs the full lifecycle:
873
+ * 1. `plan()` to collect preflight results and planned files
874
+ * 2. If any preflight returned `proceed: false`, return early without writing
875
+ * 3. `context.writeFiles()` to write files to disk (delegated to caller)
876
+ * 4. If the write was aborted, return early without calling `afterExecute`
877
+ * 5. `afterExecute` hooks for all generators with the write result
878
+ */
879
+ execute(params: TParams, context: _GeneratorExecuteContext): Promise<_GeneratorExecuteResult>;
880
+ }
881
+
882
+ /**
883
+ * Result of writing all planned files to disk.
884
+ * @internal
885
+ */
886
+ export declare interface _GeneratorWriteResult {
887
+ readonly fileOutcomes: readonly _FileWriteOutcome[];
888
+ readonly aborted: boolean;
889
+ }
890
+
891
+ /** Look up the adapter for a format. Built-ins always resolve. @internal */
892
+ export declare function _getAdapter(format: _Format): _FormatAdapter;
893
+
894
+ /** Returns `true` iff a pointer resolves to a value (including `null`) in the given root. */
895
+ /** @internal */
896
+ export declare function _hasPointer(root: unknown, pointer: _JsonPointer): boolean;
897
+
898
+ /**
899
+ * Infers a Stripe API name from a declaration's logical TypeScript name.
900
+ *
901
+ * FormSpec passes the unresolved declaration identifier through
902
+ * `logicalName`. Stripe naming policy lowers that identifier into Stripe API
903
+ * case so schema generation, lint rules, and future non-TypeScript
904
+ * implementations all share the same heuristic.
905
+ *
906
+ * @internal
907
+ */
908
+ export declare function _inferStripeApiName(context: MetadataInferenceContext): string;
909
+
910
+ /** Process-local, non-persistent state store. Useful for tests and dry-runs. */
911
+ /** @internal */
912
+ export declare function _InMemoryStateStore(): _StateStore;
913
+
914
+ /**
915
+ * Extended TemplateFS with directory scanning helpers
916
+ * @internal
917
+ */
918
+ export declare interface _InMemoryTemplateFS extends _TemplateFS {
919
+ /**
920
+ * Get all template paths under a given directory prefix
921
+ * @internal - For future directory scanning support
922
+ */
923
+ _getPathsUnder(prefix: string): string[];
924
+ }
925
+
926
+ /**
927
+ * Reusable type guards for CLI argument validation.
928
+ *
929
+ * @internal
930
+ */
931
+ /**
932
+ * Returns `true` if `value` is a non-null, non-array object.
933
+ * @internal
934
+ */
935
+ export declare function _isRecord(value: unknown): value is Record<string, unknown>;
936
+
937
+ /**
938
+ * Higher-order type guard that checks every value in a record satisfies a
939
+ * predicate.
940
+ *
941
+ * @example
942
+ * ```ts
943
+ * const isStringRecord = _isRecordWithValueType(
944
+ * (v): v is string => typeof v === 'string'
945
+ * );
946
+ * ```
947
+ * @internal
948
+ */
949
+ export declare function _isRecordWithValueType<T>(guard: (v: unknown) => v is T): (value: unknown) => value is Record<string, T>;
950
+
951
+ /** Runtime type guard. */
952
+ /** @internal */
953
+ export declare function _isSemverRange(input: unknown): input is _SemverRange;
954
+
955
+ /** Runtime type guard. */
956
+ /** @internal */
957
+ export declare function _isSemverVersion(input: unknown): input is _SemverVersion;
958
+
959
+ /**
960
+ * `true` iff `T` is exactly `unknown` (not `any`, not `never`).
961
+ * @internal
962
+ */
963
+ export declare type _IsUnknown<T> = unknown extends T ? [T] extends [null | undefined] ? false : T extends unknown ? [unknown] extends [T] ? true : false : false : false;
964
+
965
+ /** @internal */
966
+ export declare const _jsonAdapter: _FormatAdapter;
967
+
968
+ /** @internal */
969
+ export declare const _jsoncAdapter: _FormatAdapter;
970
+
971
+ /**
972
+ * A JSON Pointer string as defined by RFC 6901.
973
+ *
974
+ * Examples: `""` (whole doc), `"/dependencies/lodash"`,
975
+ * `"/compilerOptions/paths/@scope~1pkg/0"`.
976
+ */
977
+ /** @internal */
978
+ export declare type _JsonPointer = string;
979
+
980
+ /**
981
+ * Options for creating a logger instance.
982
+ *
983
+ * @internal
984
+ */
985
+ export declare interface _LoggerOptions {
986
+ /** Optional name tag included in every log record. */
987
+ readonly name?: string;
988
+ /** Log level; defaults to the LOG_LEVEL env var, falling back to 'info'. */
989
+ readonly level?: _LogLevel;
990
+ }
991
+
992
+ /**
993
+ * Log level type and parsing utilities.
994
+ *
995
+ * @internal
996
+ */
997
+ /**
998
+ * Valid pino log levels, including 'silent' to suppress all output.
999
+ *
1000
+ * @internal
1001
+ */
1002
+ export declare type _LogLevel = 'debug' | 'error' | 'fatal' | 'info' | 'silent' | 'trace' | 'warn';
1003
+
1004
+ /** Returns whether a name appears plural according to the inflector. @internal */
1005
+ export declare function _looksPlural(value: string): boolean;
1006
+
1007
+ /** Returns whether a name appears singular according to the inflector. @internal */
1008
+ export declare function _looksSingular(value: string): boolean;
1009
+
1010
+ /** Merge-operation options. */
1011
+ /** @internal */
1012
+ export declare interface _MergeOptions {
1013
+ /** Array merge strategy. Default: `"replace"`. */
1014
+ readonly arrays?: 'concat' | 'concatUnique' | 'replace';
1015
+ /** Whether to recurse into nested objects. Default: `true`. */
1016
+ readonly deep?: boolean;
1017
+ }
1018
+
1019
+ /** Per-mutation overrides. */
1020
+ /** @internal */
1021
+ export declare interface _MutationOptions<T = unknown> {
1022
+ readonly conflictPolicy?: _ConflictPolicy;
1023
+ readonly guard?: (doc: _Document<T>) => boolean;
1024
+ }
1025
+
1026
+ /** @internal */
1027
+ export declare type _NarrowedElement<T, P extends string> = string extends P ? unknown : _ValueAtPointer<T, P> extends readonly (infer E)[] ? E : unknown;
1028
+
1029
+ /** @internal */
1030
+ export declare type _NarrowedPartial<T, P extends string> = string extends P ? object : object & Partial<_ValueAtPointer<T, P>>;
1031
+
1032
+ /**
1033
+ * Narrow `_ValueAtPointer<T, P>` only when `P` is a string literal. When `P`
1034
+ * widens to `string` (e.g. a computed pointer) the type collapses to
1035
+ * `unknown` so callers keep the freedom they had before.
1036
+ * @internal
1037
+ */
1038
+ export declare type _NarrowedValue<T, P extends string> = string extends P ? unknown : _ValueAtPointer<T, P>;
1039
+
1040
+ /** @internal */
1041
+ export declare function _openApiExtractor(absolutePath: string, options?: {
1042
+ format?: 'json' | 'jsonc';
1043
+ schema?: _StandardSchemaV1;
1044
+ }): Promise<_ApiExtractorDoc>;
1045
+
1046
+ /** One-off open helper. Use a {@link _Transaction} for multi-file work. */
1047
+ /** @internal */
1048
+ export declare function _openDocument(absolutePath: string, options?: _TransactionOptions): Promise<_Document>;
1049
+
1050
+ /**
1051
+ * Open a document from disk. For non-existent files, returns an empty
1052
+ * document whose `format` is inferred from the path (or `options.format`).
1053
+ */
1054
+ /** @internal */
1055
+ export declare function _openDocumentFromDisk<T = unknown>(absolutePath: string, options?: _OpenDocumentOptions<T>): Promise<_Document<T>>;
1056
+
1057
+ /** Options passed when opening a document directly. */
1058
+ /** @internal */
1059
+ export declare interface _OpenDocumentOptions<T = unknown> {
1060
+ readonly format?: _Format;
1061
+ /** Optional schema for runtime validation (any Standard Schema). */
1062
+ readonly schema?: _StandardSchemaV1<T>;
1063
+ }
1064
+
1065
+ /**
1066
+ * Open a package.json file and return a typed façade.
1067
+ *
1068
+ * The `schema` option accepts any Standard Schema-compliant validator
1069
+ * (Zod v4, Valibot, ArkType, Effect Schema, …). It is not constrained to
1070
+ * `_StandardSchemaV1<_PackageJson>` because schema libraries typically emit
1071
+ * `string | undefined` for optional fields, which does not match exact
1072
+ * optional-property-typed interfaces structurally.
1073
+ */
1074
+ /** @internal */
1075
+ export declare function _openPackageJson(absolutePath: string, options?: {
1076
+ format?: 'json';
1077
+ schema?: _StandardSchemaV1;
1078
+ }): Promise<_PackageJsonDoc>;
1079
+
1080
+ /** @internal */
1081
+ export declare function _openStripeAppManifest(absolutePath: string, options?: {
1082
+ format?: 'json' | 'jsonc' | 'yaml';
1083
+ schema?: _StandardSchemaV1;
1084
+ }): Promise<_StripeAppManifestDoc>;
1085
+
1086
+ /** @internal */
1087
+ export declare function _openTsConfig(absolutePath: string, options?: {
1088
+ format?: 'json' | 'jsonc';
1089
+ schema?: _StandardSchemaV1;
1090
+ }): Promise<_TsConfigDoc>;
1091
+
1092
+ /** @internal */
1093
+ export declare interface _PackageJson {
1094
+ readonly name?: string;
1095
+ readonly version?: _SemverVersion | string;
1096
+ readonly scripts?: Readonly<Record<string, string>>;
1097
+ readonly dependencies?: Readonly<Record<string, _SemverRange | string>>;
1098
+ readonly devDependencies?: Readonly<Record<string, _SemverRange | string>>;
1099
+ readonly peerDependencies?: Readonly<Record<string, _SemverRange | string>>;
1100
+ readonly optionalDependencies?: Readonly<Record<string, _SemverRange | string>>;
1101
+ readonly engines?: Readonly<Record<string, _SemverRange | string>>;
1102
+ }
1103
+
1104
+ /** _Document subclass with typed package.json helpers. */
1105
+ /** @internal */
1106
+ export declare class _PackageJsonDoc extends _Document<_PackageJson> {
1107
+ setScript(name: string, command: string, opts?: _MutationOptions<_PackageJson>): this;
1108
+ requireScript(name: string, command?: string): this;
1109
+ addDependency(name: string, range: _SemverRange, kind?: _DepKind, opts?: _MutationOptions<_PackageJson>): this;
1110
+ updateDependency(name: string, range: _SemverRange, kind?: _DepKind, opts?: _MutationOptions<_PackageJson>): this;
1111
+ removeDependency(name: string, kind?: _DepKind, opts?: _MutationOptions<_PackageJson>): this;
1112
+ ensureDependency(name: string, range: _SemverRange, kind?: _DepKind, opts?: _MutationOptions<_PackageJson>): this;
1113
+ mustHaveScript(name: string, opts?: {
1114
+ equals?: string;
1115
+ matches?: RegExp;
1116
+ }): _Diagnostic[];
1117
+ mustHaveDependency(name: string, opts?: {
1118
+ kind?: _DepKind;
1119
+ range?: _SemverRange;
1120
+ }): _Diagnostic[];
1121
+ }
1122
+
1123
+ /**
1124
+ * Parse an array index token per RFC 6901: must be either `"0"` or a sequence
1125
+ * of digits `[1-9][0-9]*`. No leading zeros, no signs, no whitespace.
1126
+ *
1127
+ * Returns `null` for any invalid input (including the past-the-end token `"-"`).
1128
+ */
1129
+ /** @internal */
1130
+ export declare function _parseArrayIndex(token: string): null | number;
1131
+
1132
+ /** Input could not be parsed. */
1133
+ /** @internal */
1134
+ export declare class _ParseError extends _FileEditorError {
1135
+ readonly format: _Format;
1136
+ readonly offset: null | number;
1137
+ readonly snippet: null | string;
1138
+ constructor(format: _Format, message: string, details?: {
1139
+ offset?: number;
1140
+ snippet?: string;
1141
+ });
1142
+ }
1143
+
1144
+ /**
1145
+ * Parses a log level string, returning 'info' for missing or unrecognized values.
1146
+ *
1147
+ * @param input - Raw string (e.g. from an env var). Undefined or empty returns 'info'.
1148
+ * @returns A valid _LogLevel.
1149
+ *
1150
+ * @internal
1151
+ */
1152
+ export declare function _parseLogLevel(input: string | undefined): _LogLevel;
1153
+
1154
+ /**
1155
+ * Parse a JSON Pointer string into its decoded reference tokens.
1156
+ *
1157
+ * The empty string `""` refers to the whole document and yields `[]`.
1158
+ * `"/"` refers to the value keyed by the empty string and yields `[""]`.
1159
+ *
1160
+ * @throws {@link _PathError} if the pointer does not start with `/` (and is non-empty).
1161
+ */
1162
+ /** @internal */
1163
+ export declare function _parsePointer(pointer: _JsonPointer): _PointerSegments;
1164
+
1165
+ /** A JSON Pointer is syntactically invalid or cannot be resolved. */
1166
+ /** @internal */
1167
+ export declare class _PathError extends _FileEditorError {
1168
+ readonly pointer: _JsonPointer;
1169
+ constructor(pointer: _JsonPointer, message: string);
1170
+ }
1171
+
1172
+ /** A staged mutation, before it is serialized and written. */
1173
+ /** @internal */
1174
+ export declare interface _PendingEdit {
1175
+ readonly kind: 'addIfMissing' | 'arrayAppend' | 'arrayUpsert' | 'merge' | 'remove' | 'set' | 'updateIfPresent';
1176
+ readonly pointer: _JsonPointer;
1177
+ readonly value?: unknown;
1178
+ readonly updater?: (current: unknown) => unknown;
1179
+ readonly arrayKey?: (element: unknown) => unknown;
1180
+ readonly mergeOptions?: _MergeOptions;
1181
+ readonly conflictPolicy?: _ConflictPolicy;
1182
+ readonly guard?: (docValue: unknown) => boolean;
1183
+ }
1184
+
1185
+ /**
1186
+ * A single file that a generator intends to create.
1187
+ * @internal
1188
+ */
1189
+ export declare interface _PlannedFile {
1190
+ readonly path: string;
1191
+ readonly content: string;
1192
+ /**
1193
+ * Human-readable explanation of what this file is and why it is being
1194
+ * created. Rendered from the generator's `descriptions` map using Mustache.
1195
+ */
1196
+ readonly description?: string;
1197
+ }
1198
+
1199
+ /**
1200
+ * Proxy-based typed pointer builder. Every property access records a segment;
1201
+ * the terminal `$` property yields the RFC 6901 string.
1202
+ *
1203
+ * ```ts
1204
+ * const p = _pointer<_PackageJson>().dependencies.lodash.$; // "/dependencies/lodash"
1205
+ * ```
1206
+ */
1207
+ /** @internal */
1208
+ export declare function _pointer<T>(): _PointerBuilder<T>;
1209
+
1210
+ /** @internal */
1211
+ export declare const _POINTER_STRING: "$";
1212
+
1213
+ /** @internal */
1214
+ export declare type _PointerBuilder<T> = T extends readonly (infer U)[] ? {
1215
+ readonly [index: number]: _PointerBuilder<U>;
1216
+ readonly $: _JsonPointer;
1217
+ } : T extends object ? { readonly [K in keyof T & string]-?: _PointerBuilder<NonNullable<T[K]>> } & { readonly $: _JsonPointer } : { readonly $: _JsonPointer };
1218
+
1219
+ /** Decoded form of a JSON Pointer — an array of unescaped reference tokens. */
1220
+ /** @internal */
1221
+ export declare type _PointerSegments = readonly string[];
1222
+
1223
+ /**
1224
+ * Execute context for project-scoped generators.
1225
+ * @internal
1226
+ */
1227
+ export declare type _ProjectExecuteContext = _ProjectGeneratorContext & _WriteCapability;
1228
+
1229
+ /**
1230
+ * Generator context for a project-scoped invocation.
1231
+ * The generator places files relative to `projectRoot`.
1232
+ * @internal
1233
+ */
1234
+ export declare interface _ProjectGeneratorContext {
1235
+ readonly scope: 'project';
1236
+ readonly projectRoot: string;
1237
+ }
1238
+
1239
+ /**
1240
+ * Register or replace a format adapter.
1241
+ * @internal
1242
+ */
1243
+ export declare function _registerFormatAdapter(format: _Format, adapter: _FormatAdapter): void;
1244
+
1245
+ /**
1246
+ * Resolve a pointer against a plain JS value. Returns `undefined` if any segment
1247
+ * of the path is missing.
1248
+ *
1249
+ * Array indices must be decimal digits with no leading zeros (except `"0"` itself).
1250
+ * The special token `"-"` (past-the-end) always resolves to `undefined` here;
1251
+ * mutation operations handle it separately.
1252
+ */
1253
+ /** @internal */
1254
+ export declare function _resolvePointer(root: unknown, pointer: _JsonPointer): unknown;
1255
+
1256
+ /** @internal */
1257
+ export declare function _runAssertions(path: string, value: unknown, assertions: readonly _Assertion[]): _Diagnostic[];
1258
+
1259
+ /** @internal */
1260
+ export declare function _runAsyncAssertions(path: string, value: unknown, assertions: readonly _AsyncAssertion[]): Promise<_Diagnostic[]>;
1261
+
1262
+ /** Error thrown by {@link _validateWithSchema}. */
1263
+ /** @internal */
1264
+ export declare class _SchemaValidationError extends Error {
1265
+ readonly issues: readonly _StandardSchemaV1.Issue[];
1266
+ constructor(message: string, issues: readonly _StandardSchemaV1.Issue[]);
1267
+ }
1268
+
1269
+ /**
1270
+ * A validated npm semver range string (e.g. `"^1.2.3"`, `">=1.0 <2.0"`, `"1.x"`).
1271
+ *
1272
+ * Obtain a {@link _SemverRange} via {@link _semverRange} (throws on invalid
1273
+ * input) or {@link _tryParseSemverRange} (returns `null`).
1274
+ *
1275
+ * @see https://github.com/npm/node-semver#ranges
1276
+ */
1277
+ /** @internal */
1278
+ export declare type _SemverRange = { readonly [__semverRangeBrand]: '_SemverRange' } & string;
1279
+
1280
+ /** Validating factory for {@link _SemverRange}. Throws on invalid input. */
1281
+ /** @internal */
1282
+ export declare function _semverRange(input: string): _SemverRange;
1283
+
1284
+ /** @internal */
1285
+ export declare type _SemverVersion = { readonly [__semverVersionBrand]: '_SemverVersion' } & string;
1286
+
1287
+ /** Validating factory for {@link _SemverVersion}. Throws on invalid input. */
1288
+ /** @internal */
1289
+ export declare function _semverVersion(input: string): _SemverVersion;
1290
+
1291
+ /** Diagnostic severity. */
1292
+ /** @internal */
1293
+ export declare type _Severity = 'error' | 'info' | 'warning';
1294
+
1295
+ /** SHA-256 hex digest of arbitrary bytes (for rawSha256 tracking). */
1296
+ /** @internal */
1297
+ export declare function _sha256Hex(input: string | Uint8Array): string;
1298
+
1299
+ /**
1300
+ * Single template manager - no registry lookup needed
1301
+ * For commands that only have one template
1302
+ * @internal
1303
+ */
1304
+ export declare class _SingleTemplateManager<TParams, TOutput extends _TemplateOutput = _TemplateOutput> {
1305
+ private readonly template;
1306
+ private readonly fs;
1307
+ /**
1308
+ * Create a new SingleTemplateManager
1309
+ * @param template - The single template to use
1310
+ * @param fs - Filesystem for template file reading
1311
+ */
1312
+ constructor(template: _Template<TParams, TOutput>, fs: _TemplateFS);
1313
+ /**
1314
+ * Generate output from the template
1315
+ * @param params - Template parameters
1316
+ * @returns Template output
1317
+ */
1318
+ generate(params: TParams): Promise<TOutput>;
1319
+ }
1320
+
1321
+ /** Split a JSON Pointer string into its decoded reference tokens. */
1322
+ /** @internal */
1323
+ export declare type _SplitPointer<P extends string> = P extends '' ? [] : P extends `/${infer Rest}` ? _SplitRest<Rest> : never;
1324
+
1325
+ /** @internal */
1326
+ export declare type _SplitRest<S extends string> = S extends `${infer Head}/${infer Tail}` ? [_UnescapeToken<Head>, ..._SplitRest<Tail>] : [_UnescapeToken<S>];
1327
+
1328
+ /**
1329
+ * Execute context for standalone generators.
1330
+ * @internal
1331
+ */
1332
+ export declare type _StandaloneExecuteContext = _StandaloneGeneratorContext & _WriteCapability;
1333
+
1334
+ /**
1335
+ * Generator abstraction for composable code generation
1336
+ *
1337
+ * A generator combines a `files/` directory tree of Mustache templates,
1338
+ * a `locals()` function that computes template variables, and optional
1339
+ * lifecycle hooks for side effects (manifest updates, config changes).
1340
+ */
1341
+ /**
1342
+ * Generator context for a standalone (non-project) invocation.
1343
+ * The generator places files relative to `targetDir`.
1344
+ * @internal
1345
+ */
1346
+ export declare interface _StandaloneGeneratorContext {
1347
+ readonly scope: 'standalone';
1348
+ readonly targetDir: string;
1349
+ }
1350
+
1351
+ /**
1352
+ * Standard Schema v1 — a library-agnostic validator interface implemented by
1353
+ * Zod v4, Valibot, ArkType, Effect Schema, and others. By accepting this
1354
+ * interface we remain independent of any particular schema library.
1355
+ *
1356
+ * This module reproduces the tiny interface locally (no runtime dep).
1357
+ *
1358
+ * @see https://standardschema.dev
1359
+ * @see https://github.com/standard-schema/standard-schema
1360
+ */
1361
+ /** @internal */
1362
+ export declare namespace _StandardSchemaV1 {
1363
+ /** @internal */
1364
+ export interface Props<Input = unknown, Output = Input> {
1365
+ readonly version: 1;
1366
+ readonly vendor: string;
1367
+ readonly validate: (value: unknown) => Promise<Result<Output>> | Result<Output>;
1368
+ readonly types?: Types<Input, Output> | undefined;
1369
+ }
1370
+ /** @internal */
1371
+ export type Result<Output> = FailureResult | SuccessResult<Output>;
1372
+ /** @internal */
1373
+ export interface SuccessResult<Output> {
1374
+ readonly value: Output;
1375
+ readonly issues?: undefined;
1376
+ }
1377
+ /** @internal */
1378
+ export interface FailureResult {
1379
+ readonly issues: readonly Issue[];
1380
+ }
1381
+ /** @internal */
1382
+ export interface Issue {
1383
+ readonly message: string;
1384
+ readonly path?: readonly (PathSegment | PropertyKey)[] | undefined;
1385
+ }
1386
+ /** @internal */
1387
+ export interface PathSegment {
1388
+ readonly key: PropertyKey;
1389
+ }
1390
+ /** @internal */
1391
+ export interface Types<Input = unknown, Output = Input> {
1392
+ readonly input: Input;
1393
+ readonly output: Output;
1394
+ }
1395
+ /** Extract the inferred input type. */
1396
+ /** @internal */
1397
+ export type InferInput<S extends _StandardSchemaV1> = NonNullable<S['~standard']['types']>['input'];
1398
+ /** Extract the inferred output type. */
1399
+ /** @internal */
1400
+ export type InferOutput<S extends _StandardSchemaV1> = NonNullable<S['~standard']['types']>['output'];
1401
+ }
1402
+
1403
+ /** @internal */
1404
+ export declare interface _StandardSchemaV1<Input = unknown, Output = Input> {
1405
+ readonly '~standard': _StandardSchemaV1.Props<Input, Output>;
1406
+ }
1407
+
1408
+ /** Record kept in the state store for each managed file. */
1409
+ /** @internal */
1410
+ export declare interface _StateRecord {
1411
+ readonly fingerprint: string;
1412
+ readonly rawSha256: string;
1413
+ readonly writtenAt: string;
1414
+ readonly toolId: null | string;
1415
+ readonly toolVersion: null | string;
1416
+ readonly format: _Format;
1417
+ readonly baseText?: string;
1418
+ }
1419
+
1420
+ /**
1421
+ * Persistence contract for drift-detection state: one record per managed file,
1422
+ * keyed by absolute path. Library ships {@link _InMemoryStateStore} and
1423
+ * {@link _FsCentralManifestStore}; callers may implement their own (SQLite,
1424
+ * remote cache, etc.).
1425
+ */
1426
+ /** @internal */
1427
+ export declare interface _StateStore {
1428
+ read(absolutePath: string): Promise<_StateRecord | null>;
1429
+ write(absolutePath: string, record: _StateRecord): Promise<void>;
1430
+ delete(absolutePath: string): Promise<void>;
1431
+ /** Optional enumeration for maintenance/GC tasks. */
1432
+ list?(): Promise<readonly {
1433
+ path: string;
1434
+ record: _StateRecord;
1435
+ }[]>;
1436
+ }
1437
+
1438
+ /** @internal */
1439
+ export declare type _StepInto<T, First extends string, Rest extends readonly string[]> = T extends readonly [unknown, ...unknown[]] ? First extends keyof T ? _ValueAtSegments<NonNullable<T[First]>, Rest> : unknown : T extends readonly (infer E)[] ? First extends `${number}` ? _ValueAtSegments<E, Rest> : unknown : T extends object ? First extends keyof T ? _ValueAtSegments<NonNullable<T[First]>, Rest> : string extends keyof T ? _ValueAtSegments<NonNullable<T[keyof T & string]>, Rest> : unknown : unknown;
1440
+
1441
+ /** @internal */
1442
+ export declare interface _StripeAppManifest {
1443
+ readonly id?: string;
1444
+ readonly name?: string;
1445
+ readonly version?: _SemverVersion | string;
1446
+ readonly permissions?: readonly _StripePermission[];
1447
+ readonly app_backend?: unknown;
1448
+ readonly ui_extension?: unknown;
1449
+ readonly custom_object_definitions?: { readonly definitions?: readonly {
1450
+ readonly id: string;
1451
+ readonly specification: {
1452
+ readonly content: string;
1453
+ readonly type: string;
1454
+ };
1455
+ }[] };
1456
+ }
1457
+
1458
+ /** @internal */
1459
+ export declare class _StripeAppManifestDoc extends _Document<_StripeAppManifest> {
1460
+ setName(name: string, opts?: _MutationOptions<_StripeAppManifest>): this;
1461
+ setVersion(version: _SemverVersion, opts?: _MutationOptions<_StripeAppManifest>): this;
1462
+ addPermission(permission: _StripePermission, opts?: _MutationOptions<_StripeAppManifest>): this;
1463
+ removePermission(permission: _StripePermission, opts?: _MutationOptions<_StripeAppManifest>): this;
1464
+ /**
1465
+ * Add a custom object definition. Uses arrayUpsert to avoid duplicates
1466
+ * (keyed on `id`). Creates the `custom_object_definitions.definitions`
1467
+ * array if it doesn't exist.
1468
+ */
1469
+ addCustomObject(id: string, content: string, type?: string, opts?: _MutationOptions<_StripeAppManifest>): this;
1470
+ /**
1471
+ * Check if a custom object definition exists by id.
1472
+ */
1473
+ hasCustomObject(id: string): boolean;
1474
+ }
1475
+
1476
+ /**
1477
+ * Stripe metadata policy for FormSpec schema generation.
1478
+ *
1479
+ * Singular `apiName` and `displayName` values are inferred whenever they are
1480
+ * absent. Type declarations also get inferred plural forms so custom-object
1481
+ * and extension tooling can share the same resolved metadata contract.
1482
+ *
1483
+ * @internal
1484
+ */
1485
+ export declare const _stripeMetadataPolicy: MetadataPolicyInput;
1486
+
1487
+ /**
1488
+ * Stripe app permission strings follow the convention `{verb}_{resource}` —
1489
+ * e.g. `read_customers`, `write_products`. The template literal enforces the
1490
+ * prefix while keeping the resource portion open so the type doesn't go
1491
+ * stale as Stripe adds resources.
1492
+ *
1493
+ * @see https://docs.stripe.com/stripe-apps/reference/permissions
1494
+ */
1495
+ /** @internal */
1496
+ export declare type _StripePermission = `${'read' | 'write'}_${string}`;
1497
+
1498
+ /**
1499
+ * Template definition
1500
+ * Wraps a generate function with any associated metadata
1501
+ *
1502
+ * @typeParam TParams - Parameters for template generation
1503
+ * @typeParam TOutput - Output type (must extend TemplateOutput)
1504
+ * @internal
1505
+ */
1506
+ export declare interface _Template<TParams, TOutput extends _TemplateOutput = _TemplateOutput> {
1507
+ /**
1508
+ * Generate files and other output from the template
1509
+ */
1510
+ generate(params: TParams, context: _TemplateContext): Promise<TOutput> | TOutput;
1511
+ }
1512
+
1513
+ /**
1514
+ * Context for template generation
1515
+ * Provides optional capabilities like file reading and user prompts
1516
+ * Templates can ignore this parameter if they don't need these features
1517
+ * @internal
1518
+ */
1519
+ export declare interface _TemplateContext {
1520
+ /**
1521
+ * Filesystem abstraction for reading template files
1522
+ */
1523
+ fs: _TemplateFS;
1524
+ }
1525
+
1526
+ /**
1527
+ * Filesystem abstraction for template factories
1528
+ * @internal
1529
+ */
1530
+ export declare interface _TemplateFS {
1531
+ /**
1532
+ * Read a text file relative to the templates directory
1533
+ *
1534
+ * Note: Only supports text files. Binary files are not supported by the
1535
+ * current implementation (template content is embedded as strings during
1536
+ * CJS bundling, which doesn't work for binary data).
1537
+ */
1538
+ textFile(...segments: string[]): string;
1539
+ /**
1540
+ * Read a file and process it with Mustache template engine
1541
+ * @param params - Parameters to pass to the template
1542
+ * @param segments - Path segments to the template file
1543
+ */
1544
+ mustache(params: Record<string, unknown>, ...segments: string[]): string;
1545
+ /**
1546
+ * Create a scoped TemplateFS with an implicit path prefix
1547
+ * @param prefix - Path segment to prepend to all operations
1548
+ * @returns New TemplateFS instance with the prefix applied
1549
+ */
1550
+ scope(prefix: string): _TemplateFS;
1551
+ }
1552
+
1553
+ /**
1554
+ * Template entry in the in-memory registry
1555
+ * @internal
1556
+ */
1557
+ export declare interface _TemplateFSImageEntry {
1558
+ path: string;
1559
+ content: string;
1560
+ }
1561
+
1562
+ /**
1563
+ * Generic template manager
1564
+ * Manages template selection and generation with full type safety
1565
+ *
1566
+ * @typeParam TParams - Template parameters type
1567
+ * @typeParam TOutput - Template output type (must extend TemplateOutput)
1568
+ * @typeParam TTemplate - Concrete template type (defaults to Template; specify to preserve extra fields in getTemplateEntries)
1569
+ * @internal
1570
+ */
1571
+ export declare class _TemplateManager<TParams, TOutput extends _TemplateOutput = _TemplateOutput, TTemplate extends _Template<TParams, TOutput> = _Template<TParams, TOutput>> {
1572
+ private readonly templates;
1573
+ private readonly fs;
1574
+ /**
1575
+ * Create a new TemplateManager
1576
+ * @param templates - Object mapping string keys to templates
1577
+ * @param fs - Filesystem abstraction for template file reading
1578
+ *
1579
+ * @example
1580
+ * ```typescript
1581
+ * import { fs } from './fs/index.js';
1582
+ *
1583
+ * const manager = new TemplateManager({
1584
+ * foo: fooTemplate,
1585
+ * bar: barTemplate,
1586
+ * }, fs)
1587
+ *
1588
+ * await manager.generate('foo', params)
1589
+ * ```
1590
+ */
1591
+ constructor(templates: Record<string, TTemplate>, fs: _TemplateFS);
1592
+ /**
1593
+ * Generate output from a template
1594
+ * @param key - Template key to generate from
1595
+ * @param params - Template-specific parameters
1596
+ * @returns Template output with files and any additional fields
1597
+ * @throws Error if template key is not found
1598
+ */
1599
+ generate(key: string, params: TParams): Promise<TOutput>;
1600
+ /**
1601
+ * Get all template entries as [key, template] pairs
1602
+ */
1603
+ protected getTemplateEntries(): [string, TTemplate][];
1604
+ /**
1605
+ * Get list of all supported template keys
1606
+ */
1607
+ getSupportedKeys(): string[];
1608
+ }
1609
+
1610
+ /**
1611
+ * Base template output - always includes files array
1612
+ * Extend this interface to add additional output fields
1613
+ * @internal
1614
+ */
1615
+ export declare interface _TemplateOutput {
1616
+ /** Files to write to disk. */
1617
+ files: _GeneratedFile[];
1618
+ }
1619
+
1620
+ /** Capitalizes the first character of a string, leaving the rest unchanged. @internal */
1621
+ export declare function _toCapitalized(value: string): string;
1622
+
1623
+ /** Tokenizes an identifier into words using Stripe API case heuristics. @internal */
1624
+ export declare function _tokenizeIdentifier(input: string): string[];
1625
+
1626
+ /** Converts a snake_case identifier to PascalCase. @internal */
1627
+ export declare function _toPascalCase(value: string): string;
1628
+
1629
+ /** Pluralizes a name using the `inflected` library. @internal */
1630
+ export declare function _toPlural(value: string): string;
1631
+
1632
+ /** Converts an identifier into a sentence-case display name. @internal */
1633
+ export declare function _toSentenceDisplayName(input: string): string;
1634
+
1635
+ /** Singularizes a name using the `inflected` library. @internal */
1636
+ export declare function _toSingular(value: string): string;
1637
+
1638
+ /** Converts a PascalCase or camelCase identifier to snake_case. @internal */
1639
+ export declare function _toSnakeCase(value: string): string;
1640
+
1641
+ /** Converts an identifier into Stripe API case. @internal */
1642
+ export declare function _toStripeApiCase(input: string): string;
1643
+
1644
+ /** An editing session spanning one or more documents. */
1645
+ /** @internal */
1646
+ export declare class _Transaction {
1647
+ private readonly documents;
1648
+ private readonly options;
1649
+ constructor(options?: _TransactionOptions);
1650
+ /** Open or return the cached document for a path. Memoized per transaction. */
1651
+ open(absolutePath: string): Promise<_Document>;
1652
+ /** @internal — register a document that was opened externally (e.g. via a façade). */
1653
+ adopt(doc: _Document): void;
1654
+ /** Drop all staged edits across every document in the transaction. */
1655
+ rollback(): void;
1656
+ /** Plan without writing. Invokes `onConflict`/`confirmWrite` as a real commit would. */
1657
+ dryRun(options?: _CommitOptions): Promise<_CommitReport>;
1658
+ /** Apply staged edits to disk. */
1659
+ commit(options?: _CommitOptions): Promise<_CommitReport>;
1660
+ private run;
1661
+ }
1662
+
1663
+ /** Options common to opening documents inside a transaction. */
1664
+ /** @internal */
1665
+ export declare interface _TransactionOptions {
1666
+ readonly format?: _Format;
1667
+ readonly stateStore?: _StateStore;
1668
+ readonly onConflict?: _ConflictResolver;
1669
+ readonly confirmWrite?: _WriteConfirm;
1670
+ readonly confirmationPolicy?: _ConfirmationPolicy;
1671
+ readonly toolId?: string;
1672
+ readonly toolVersion?: string;
1673
+ }
1674
+
1675
+ /** Truncates a name to a maximum length without additional normalization. @internal */
1676
+ export declare function _truncateName(value: string, maxLength: number): string;
1677
+
1678
+ /** Non-throwing variant of {@link _semverRange}. */
1679
+ /** @internal */
1680
+ export declare function _tryParseSemverRange(input: string): _SemverRange | null;
1681
+
1682
+ /** Non-throwing variant of {@link _semverVersion}. */
1683
+ /** @internal */
1684
+ export declare function _tryParseSemverVersion(input: string): _SemverVersion | null;
1685
+
1686
+ /** Non-throwing variant returning the Standard Schema result directly. */
1687
+ /** @internal */
1688
+ export declare function _tryValidateWithSchema<S extends _StandardSchemaV1>(schema: S, value: unknown): Promise<_StandardSchemaV1.Result<_StandardSchemaV1.InferOutput<S>>>;
1689
+
1690
+ /** @internal */
1691
+ export declare interface _TsConfig {
1692
+ readonly extends?: readonly string[] | string;
1693
+ readonly compilerOptions?: _CompilerOptions;
1694
+ readonly include?: readonly string[];
1695
+ readonly exclude?: readonly string[];
1696
+ readonly files?: readonly string[];
1697
+ readonly references?: readonly { readonly path: string }[];
1698
+ }
1699
+
1700
+ /** @internal */
1701
+ export declare class _TsConfigDoc extends _Document<_TsConfig> {
1702
+ setCompilerOption<K extends _CompilerOptionKey>(name: K, value: _CompilerOptionValue<K>, opts?: _MutationOptions<_TsConfig>): this;
1703
+ ensureCompilerOption<K extends _CompilerOptionKey>(name: K, value: _CompilerOptionValue<K>, opts?: _MutationOptions<_TsConfig>): this;
1704
+ addInclude(pattern: string, opts?: _MutationOptions<_TsConfig>): this;
1705
+ addExclude(pattern: string, opts?: _MutationOptions<_TsConfig>): this;
1706
+ addReference(path: string, opts?: _MutationOptions<_TsConfig>): this;
1707
+ mustHaveCompilerOption<K extends _CompilerOptionKey>(name: K, opts?: {
1708
+ readonly equals?: _CompilerOptionValue<K>;
1709
+ readonly oneOf?: readonly _CompilerOptionValue<K>[];
1710
+ }): _Diagnostic[];
1711
+ }
1712
+
1713
+ /** @internal */
1714
+ export declare type _TsJsx = 'preserve' | 'react-jsx' | 'react-jsxdev' | 'react-native' | 'react';
1715
+
1716
+ /** @internal */
1717
+ export declare type _TsModule = 'AMD' | 'CommonJS' | 'ES2015' | 'ES2020' | 'ES2022' | 'ES6' | 'ESNext' | 'Node16' | 'NodeNext' | 'None' | 'Preserve' | 'System' | 'UMD';
1718
+
1719
+ /** @internal */
1720
+ export declare type _TsModuleResolution = 'Bundler' | 'Classic' | 'Node' | 'Node10' | 'Node16' | 'NodeNext';
1721
+
1722
+ /**
1723
+ * Typed surface for tsconfig.json `compilerOptions`. Covers the keys most
1724
+ * commonly touched by build tooling; keys outside this set remain editable
1725
+ * through the generic {@link _Document} API as an escape hatch.
1726
+ *
1727
+ * @see https://www.typescriptlang.org/tsconfig
1728
+ */
1729
+ /** Canonical TypeScript language-target values. */
1730
+ /** @internal */
1731
+ export declare type _TsTarget = 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ES2021' | 'ES2022' | 'ES2023' | 'ES2024' | 'ES3' | 'ES5' | 'ES6' | 'ESNext';
1732
+
1733
+ /** A mutation's expected shape doesn't match the current value. */
1734
+ /** @internal */
1735
+ export declare class _TypeMismatchError extends _FileEditorError {
1736
+ readonly pointer: _JsonPointer;
1737
+ constructor(pointer: _JsonPointer, message: string);
1738
+ }
1739
+
1740
+ /**
1741
+ * Type-level arithmetic for resolving the value type at a JSON Pointer,
1742
+ * given a known schema type.
1743
+ *
1744
+ * `_ValueAtPointer<T, P>` walks `T` segment-by-segment along the decoded
1745
+ * _pointer string `P` and yields the value type at that location. For
1746
+ * unknown or structurally impossible paths it falls back to `unknown`,
1747
+ * so a typed `set(_pointer, value)` signature rejects values that couldn't
1748
+ * possibly belong at that location.
1749
+ *
1750
+ * This entire module is *types only* at runtime — zero code is emitted.
1751
+ *
1752
+ * @see https://datatracker.ietf.org/doc/html/rfc6901
1753
+ */
1754
+ /** Unescape a single reference token per RFC 6901 (§4). */
1755
+ /** @internal */
1756
+ export declare type _UnescapeToken<S extends string> = S extends `${infer H}~1${infer T}` ? `${H}/${_UnescapeToken<T>}` : S extends `${infer H}~0${infer T}` ? `${H}~${_UnescapeToken<T>}` : S;
1757
+
1758
+ /** Unescape a single JSON Pointer reference token (RFC 6901 §4). */
1759
+ /** @internal */
1760
+ export declare function _unescapeToken(token: string): string;
1761
+
1762
+ /** Validates a Stripe API name. @internal */
1763
+ export declare function _validateApiName(value: string): _ApiNameValidationResult;
1764
+
1765
+ /** Validates a display name. @internal */
1766
+ export declare function _validateDisplayName(value: string): _ApiNameValidationResult;
1767
+
1768
+ /**
1769
+ * Validate a value against a Standard Schema. Awaits the validator if it
1770
+ * returns a promise. Returns the parsed value on success, throws on failure
1771
+ * with a formatted message.
1772
+ */
1773
+ /** @internal */
1774
+ export declare function _validateWithSchema<S extends _StandardSchemaV1>(schema: S, value: unknown): Promise<_StandardSchemaV1.InferOutput<S>>;
1775
+
1776
+ /**
1777
+ * Given a schema type `T` and a JSON Pointer string literal `P`, the value
1778
+ * type at the _pointer's location. Empty _pointer yields `T` itself.
1779
+ *
1780
+ * When `T` is `unknown` the arithmetic collapses to `unknown`, so the
1781
+ * generic `_Document<unknown>` transparently accepts any value.
1782
+ * @internal
1783
+ */
1784
+ export declare type _ValueAtPointer<T, P extends string> = _IsUnknown<T> extends true ? unknown : _ValueAtSegments<T, _SplitPointer<P>>;
1785
+
1786
+ /**
1787
+ * Walk a schema type `T` along a sequence of reference tokens `S`,
1788
+ * yielding the value type at that location (or `unknown` for structurally
1789
+ * impossible paths).
1790
+ * @internal
1791
+ */
1792
+ export declare type _ValueAtSegments<T, S extends readonly string[]> = S extends readonly [] ? T : S extends readonly [infer First extends string, ...infer Rest extends string[]] ? _StepInto<T, First, Rest> : unknown;
1793
+
1794
+ /**
1795
+ * Look up the current version for a workspace package.
1796
+ *
1797
+ * Throws if the package is not in the manifest — this catches typos at
1798
+ * build time rather than producing a silent `undefined`.
1799
+ * @internal
1800
+ */
1801
+ export declare function _workspaceVersion(packageName: string): string;
1802
+
1803
+ /** confirmWrite returned "abort". */
1804
+ /** @internal */
1805
+ export declare class _WriteAbortedError extends _FileEditorError {
1806
+ readonly path: string;
1807
+ constructor(path: string);
1808
+ }
1809
+
1810
+ /**
1811
+ * Capability mixin that adds `writeFiles` to an execute context.
1812
+ * @internal
1813
+ */
1814
+ export declare interface _WriteCapability {
1815
+ /** Write generated files to disk. Provided by the caller. */
1816
+ writeFiles(files: readonly _PlannedFile[]): Promise<_GeneratorWriteResult>;
1817
+ }
1818
+
1819
+ /** @internal */
1820
+ export declare type _WriteConfirm = (req: _WriteRequest) => Promise<_WriteDecision>;
1821
+
1822
+ /** Result of a write-confirmation request. */
1823
+ /** @internal */
1824
+ export declare type _WriteDecision = 'abort' | 'skip' | 'write';
1825
+
1826
+ /**
1827
+ * Error detail attached to a file write outcome.
1828
+ * @internal
1829
+ */
1830
+ export declare interface _WriteError {
1831
+ readonly kind: 'conflict' | 'disk' | 'permission' | 'unknown';
1832
+ readonly message: string;
1833
+ }
1834
+
1835
+ /**
1836
+ * Write a JSON result to the given file path, or no-op if no path is provided.
1837
+ *
1838
+ * Used by CLI binaries that support `--output-path <file>` for structured
1839
+ * output. When the flag is omitted the caller handles human-readable output
1840
+ * to stdout instead.
1841
+ *
1842
+ * @internal
1843
+ */
1844
+ export declare function _writeJsonOutput(outputPath: string | undefined, data: unknown): void;
1845
+
1846
+ /** Reason the library is requesting a write. */
1847
+ /** @internal */
1848
+ export declare type _WriteReason = 'conflict' | 'new-file' | 'update';
1849
+
1850
+ /** Payload handed to the caller-supplied `confirmWrite` hook. */
1851
+ /** @internal */
1852
+ export declare interface _WriteRequest {
1853
+ readonly path: string;
1854
+ readonly format: _Format;
1855
+ readonly reason: _WriteReason;
1856
+ readonly currentText: null | string;
1857
+ readonly nextText: string;
1858
+ readonly unifiedDiff: string;
1859
+ readonly hunks: readonly _DiffHunk[];
1860
+ readonly conflict: _Conflict | null;
1861
+ }
1862
+
1863
+ /** @internal */
1864
+ export declare const _yamlAdapter: _FormatAdapter;
1865
+
1866
+ export { }