@stripe/extensibility-dev-tools 0.23.5 → 0.24.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.
- package/README.md +28 -0
- package/dist/bin/build-custom-object-definitions.cjs +42 -36
- package/dist/bin/build-custom-object-definitions.js +42 -36
- package/dist/bin/create-upload-image.cjs +42 -36
- package/dist/bin/create-upload-image.js +42 -36
- package/dist/bin/dev-tools-rpc.cjs +42 -31
- package/dist/bin/dev-tools-rpc.js +42 -31
- package/dist/bin/gen-workspace.cjs +42 -31
- package/dist/bin/gen-workspace.js +42 -31
- package/dist/bin/template-info.cjs +28 -30
- package/dist/bin/template-info.js +28 -30
- package/dist/custom-objects/to-proto-json.d.ts +2 -1
- package/dist/custom-objects/to-proto-json.d.ts.map +1 -1
- package/dist/index.cjs +42 -31
- package/dist/index.js +42 -31
- package/dist/templates/extensions/base.d.ts +1 -1
- package/dist/templates/extensions/base.d.ts.map +1 -1
- package/dist/templates/extensions/core.workflows.custom_action.d.ts.map +1 -1
- package/dist/templates/index.cjs +42 -31
- package/dist/templates/index.js +42 -31
- package/dist/templates/root/index.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/workspace/index.cjs +42 -31
- package/dist/workspace/index.js +42 -31
- package/package.json +4 -4
- package/templates/extensions/billing.bill.discount_calculation/index.ts +2 -3
- package/templates/extensions/billing.customer_balance_application/index.test.ts +5 -5
- package/templates/extensions/billing.customer_balance_application/index.ts +4 -4
- package/templates/extensions/billing.invoice_collection_setting/index.ts +2 -2
- package/templates/extensions/billing.prorations/index.ts +2 -2
- package/templates/extensions/billing.recurring_billing_item_handling/index.ts +2 -2
- package/templates/extensions/core.workflows.custom_action/index.ts +2 -3
- package/templates/extensions/extend.workflows.custom_action/index.ts +2 -3
- package/templates/root/custom-objects/{package.json → package.json.mustache} +4 -4
- package/dist/extensibility-dev-tools-alpha.d.ts +0 -199
- package/dist/extensibility-dev-tools-beta.d.ts +0 -199
- package/dist/extensibility-dev-tools-dependencies-alpha.d.ts +0 -51
- package/dist/extensibility-dev-tools-dependencies-beta.d.ts +0 -51
- package/dist/extensibility-dev-tools-dependencies-internal.d.ts +0 -372
- package/dist/extensibility-dev-tools-dependencies-public.d.ts +0 -51
- package/dist/extensibility-dev-tools-internal.d.ts +0 -1722
- package/dist/extensibility-dev-tools-jsonschema-tools-alpha.d.ts +0 -57
- package/dist/extensibility-dev-tools-jsonschema-tools-beta.d.ts +0 -57
- package/dist/extensibility-dev-tools-jsonschema-tools-internal.d.ts +0 -123
- package/dist/extensibility-dev-tools-jsonschema-tools-public.d.ts +0 -57
- package/dist/extensibility-dev-tools-manifest-alpha.d.ts +0 -31
- package/dist/extensibility-dev-tools-manifest-beta.d.ts +0 -31
- package/dist/extensibility-dev-tools-manifest-internal.d.ts +0 -461
- package/dist/extensibility-dev-tools-manifest-public.d.ts +0 -31
- package/dist/extensibility-dev-tools-public.d.ts +0 -199
- package/dist/extensibility-dev-tools-schemas-alpha.d.ts +0 -9
- package/dist/extensibility-dev-tools-schemas-beta.d.ts +0 -9
- package/dist/extensibility-dev-tools-schemas-internal.d.ts +0 -41
- package/dist/extensibility-dev-tools-schemas-public.d.ts +0 -9
- package/dist/extensibility-dev-tools-templates-alpha.d.ts +0 -67
- package/dist/extensibility-dev-tools-templates-beta.d.ts +0 -67
- package/dist/extensibility-dev-tools-templates-internal.d.ts +0 -554
- package/dist/extensibility-dev-tools-templates-public.d.ts +0 -67
- package/dist/extensibility-dev-tools-workspace-alpha.d.ts +0 -51
- package/dist/extensibility-dev-tools-workspace-beta.d.ts +0 -51
- package/dist/extensibility-dev-tools-workspace-internal.d.ts +0 -410
- package/dist/extensibility-dev-tools-workspace-public.d.ts +0 -51
|
@@ -1,1722 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@stripe/extensibility-dev-tools`
|
|
3
|
-
*
|
|
4
|
-
* Development tools for Stripe Apps extension projects:
|
|
5
|
-
* - Template system for code generation
|
|
6
|
-
* - Dependency management
|
|
7
|
-
* - Manifest parsing (stripe-app.yaml)
|
|
8
|
-
* - Workspace regeneration
|
|
9
|
-
*
|
|
10
|
-
* @packageDocumentation
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { z } from 'zod';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Shows an advanced diff viewer with scrolling and colorized output.
|
|
17
|
-
* Falls back to basic prompt if not in a TTY or on error.
|
|
18
|
-
*
|
|
19
|
-
* @param filePath - Relative path to the file (for display)
|
|
20
|
-
* @param cwd - Working directory to resolve the path from
|
|
21
|
-
* @param newContent - New content that would be written
|
|
22
|
-
* @returns User's decision about overwriting
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
export declare function _advancedDiffPrompt(filePath: string, cwd: string, newContent: string): Promise<_OverwriteDecision>;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Result of checking whether a dependency is satisfied.
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export declare interface _CheckResult {
|
|
32
|
-
/** Whether the dependency requirement is currently satisfied. */
|
|
33
|
-
satisfied: boolean;
|
|
34
|
-
/** The currently installed version, if any. */
|
|
35
|
-
currentVersion?: string;
|
|
36
|
-
/** Human-readable message describing the check result. */
|
|
37
|
-
message: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Shared context threaded through CLI operations.
|
|
42
|
-
*
|
|
43
|
-
* Carry this through call chains so that output can be redirected in tests
|
|
44
|
-
* without patching global `process.stdout`/`process.stderr`.
|
|
45
|
-
*
|
|
46
|
-
* @internal
|
|
47
|
-
*/
|
|
48
|
-
export declare interface _CliContext {
|
|
49
|
-
/** Output abstraction for writing to stdout/stderr. */
|
|
50
|
-
readonly ux: _CliUx;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Thin output abstraction used by CLI entry points and the functions they call.
|
|
55
|
-
*
|
|
56
|
-
* Inject a `_CliUx` constructed with `PassThrough` streams in tests to capture
|
|
57
|
-
* output without spying on `process.stdout`/`process.stderr`.
|
|
58
|
-
*
|
|
59
|
-
* @internal
|
|
60
|
-
*/
|
|
61
|
-
export declare class _CliUx {
|
|
62
|
-
#private;
|
|
63
|
-
constructor(options?: {
|
|
64
|
-
readonly stderr?: NodeJS.WritableStream;
|
|
65
|
-
readonly stdout?: NodeJS.WritableStream;
|
|
66
|
-
});
|
|
67
|
-
/** Write a product output line to stdout (or the configured stream). */
|
|
68
|
-
print(message: string): void;
|
|
69
|
-
/** Write a status/progress line to stderr (or the configured stream). */
|
|
70
|
-
log(message: string): void;
|
|
71
|
-
/**
|
|
72
|
-
* Error message to **stderr** (or the configured stderr stream).
|
|
73
|
-
*
|
|
74
|
-
* Behaviorally identical to {@link _CliUx.log} today. Use `error()` for failures
|
|
75
|
-
* and `log()` for progress/status — the distinction supports future
|
|
76
|
-
* formatting differentiation (color, prefixes, severity filtering).
|
|
77
|
-
*/
|
|
78
|
-
error(message: string): void;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Options for committing accumulated dependency changes.
|
|
83
|
-
* @internal
|
|
84
|
-
*/
|
|
85
|
-
export declare interface _CommitOptions {
|
|
86
|
-
/** If true, run package manager install for npm deps. Default: true */
|
|
87
|
-
runInstall?: boolean;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Summary of changes applied by a dependency manager commit.
|
|
92
|
-
* @internal
|
|
93
|
-
*/
|
|
94
|
-
export declare interface _CommitResult {
|
|
95
|
-
/** Number of new dependencies added. */
|
|
96
|
-
added: number;
|
|
97
|
-
/** Number of existing dependencies updated. */
|
|
98
|
-
updated: number;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Result of checking whether a dependency version conflicts with an existing installation.
|
|
103
|
-
* @internal
|
|
104
|
-
*/
|
|
105
|
-
export declare interface _ConflictResult {
|
|
106
|
-
/** Whether a version conflict exists. */
|
|
107
|
-
hasConflict: boolean;
|
|
108
|
-
/** The version currently installed, if any. */
|
|
109
|
-
existingVersion?: string;
|
|
110
|
-
/** The version being requested, if applicable. */
|
|
111
|
-
requestedVersion?: string;
|
|
112
|
-
/** Human-readable message describing the conflict, if any. */
|
|
113
|
-
message?: string;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Create a `_CliContext` with default or injected collaborators.
|
|
118
|
-
*
|
|
119
|
-
* @param options - Optional options. Pass a pre-constructed `_CliUx` to redirect output
|
|
120
|
-
* streams (e.g., for testing or RPC transports that must not write to stdout).
|
|
121
|
-
* @internal
|
|
122
|
-
*/
|
|
123
|
-
export declare function _createCliContext(options?: { ux?: _CliUx }): _CliContext;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Generate the ESLint config file for an extension workspace.
|
|
127
|
-
* @internal
|
|
128
|
-
*/
|
|
129
|
-
export declare function _createExtensionEslintConfigFile(params: { extensionInterfaceId: string } & Pick<_ExtensionParams, 'id'>, context: _TemplateContext): _GeneratedFile;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Helper for creating a SingleTemplateManager with simple single-file generation
|
|
133
|
-
*
|
|
134
|
-
* @param generateContent - Function that generates file content from parameters
|
|
135
|
-
* @param pathTemplate - Function that generates file path from parameters
|
|
136
|
-
* @returns SingleTemplateManager ready to use
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* ```typescript
|
|
140
|
-
* interface MyParams {
|
|
141
|
-
* name: string
|
|
142
|
-
* }
|
|
143
|
-
*
|
|
144
|
-
* // Simple template that generates content from parameters
|
|
145
|
-
* const templateManager = createSimpleSingleFileTemplate<MyParams>(
|
|
146
|
-
* (params) => `export class ${params.name} { ... }`,
|
|
147
|
-
* (params) => `src/${snakeCase(params.name)}.ts`
|
|
148
|
-
* )
|
|
149
|
-
*
|
|
150
|
-
* const output = await templateManager.generate({ name: 'MyClass' })
|
|
151
|
-
* // output.files[0] = { path: 'src/my_class.ts', content: '...' }
|
|
152
|
-
* ```
|
|
153
|
-
* @internal
|
|
154
|
-
*/
|
|
155
|
-
export declare function _createSimpleSingleFileTemplate<TParams>(generateContent: (params: TParams) => string, pathTemplate: (params: TParams) => string): _SingleTemplateManager<TParams>;
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Convert a simple content generator to a full Template
|
|
159
|
-
* @param generateContent - Function that generates file content from parameters
|
|
160
|
-
* @param pathTemplate - Function that generates file path from parameters
|
|
161
|
-
* @returns Full Template implementation
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* ```typescript
|
|
165
|
-
* interface MyParams {
|
|
166
|
-
* name: string
|
|
167
|
-
* version: string
|
|
168
|
-
* }
|
|
169
|
-
*
|
|
170
|
-
* const template = createSimpleTemplate<MyParams>(
|
|
171
|
-
* (params) => `export const ${params.name} = "${params.version}";`,
|
|
172
|
-
* (params) => `src/${snakeCase(params.name)}.ts`
|
|
173
|
-
* )
|
|
174
|
-
* ```
|
|
175
|
-
* @internal
|
|
176
|
-
*/
|
|
177
|
-
export declare function _createSimpleTemplate<TParams>(generateContent: (params: TParams) => string, pathTemplate: (params: TParams) => string): _Template<TParams>;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Custom object definition (internal representation with separate fields)
|
|
181
|
-
* @internal
|
|
182
|
-
*/
|
|
183
|
-
export declare interface _CustomObjectDefinition {
|
|
184
|
-
/** Object identifier (e.g., "device", "loyalty_card") */
|
|
185
|
-
id: string;
|
|
186
|
-
/** Specification type (e.g., "typescript") */
|
|
187
|
-
type: string;
|
|
188
|
-
/** Path to the definition file */
|
|
189
|
-
path: string;
|
|
190
|
-
/** Export name derived from id via PascalCase (e.g., "Device", "LoyaltyCard") */
|
|
191
|
-
name: string;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Wrapper for custom_object_definitions in the manifest.
|
|
196
|
-
* @internal
|
|
197
|
-
*/
|
|
198
|
-
export declare interface _CustomObjectDefinitionsBlock {
|
|
199
|
-
/** List of custom object definition entries. */
|
|
200
|
-
definitions?: _CustomObjectDefinitionYaml[];
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Custom object definition as stored in YAML (nested under definitions).
|
|
205
|
-
*
|
|
206
|
-
* `id` is the source of truth for identity. The export name used at build time
|
|
207
|
-
* is derived via `_toPascalCase(id)`, so `id` must be valid snake_case that
|
|
208
|
-
* round-trips cleanly (e.g., `device`, `loyalty_card`, `http_request`).
|
|
209
|
-
* Consecutive-uppercase class names like `MyHTTPClient` are NOT round-trip safe
|
|
210
|
-
* (`my_http_client` → `MyHttpClient`). A future `export_name` field may address
|
|
211
|
-
* this; for now, avoid ids that would produce ambiguous PascalCase names.
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```yaml
|
|
215
|
-
* custom_object_definitions:
|
|
216
|
-
* definitions:
|
|
217
|
-
* - id: device
|
|
218
|
-
* specification:
|
|
219
|
-
* type: typescript
|
|
220
|
-
* content: src/device.object.ts
|
|
221
|
-
* ```
|
|
222
|
-
*
|
|
223
|
-
* @internal
|
|
224
|
-
*/
|
|
225
|
-
export declare interface _CustomObjectDefinitionYaml {
|
|
226
|
-
/** Object identifier (e.g., `device`, `loyalty_card`). */
|
|
227
|
-
id: string;
|
|
228
|
-
/** Specification describing the type and source file for the definition. */
|
|
229
|
-
specification: {
|
|
230
|
-
content: string;
|
|
231
|
-
type: string;
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* A parsed custom object entry referencing a file path and export class name.
|
|
237
|
-
* @internal
|
|
238
|
-
*/
|
|
239
|
-
export declare interface _CustomObjectEntry {
|
|
240
|
-
/** Relative path to the type definition file (e.g., `src/device.d.ts`). */
|
|
241
|
-
filePath: string;
|
|
242
|
-
/** Name of the exported class in the definition file. */
|
|
243
|
-
className: string;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Default workspace services using real filesystem and dependency implementations.
|
|
248
|
-
* @internal
|
|
249
|
-
*/
|
|
250
|
-
export declare const _defaultServices: _WorkspaceServices;
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* A dependency that the workspace needs: npm runtime, npm dev, or Stripe CLI plugin.
|
|
254
|
-
* @internal
|
|
255
|
-
*/
|
|
256
|
-
export declare type _Dependency = _DevNpmDependency | _NpmDependency | _StripeCliPluginDependency;
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* The action to take for a dependency: add new, update existing, no-op, or flag a conflict.
|
|
260
|
-
* @internal
|
|
261
|
-
*/
|
|
262
|
-
export declare type _DependencyAction = 'add' | 'already-satisfied' | 'conflict' | 'update';
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Handler interface for a specific dependency type (npm or Stripe CLI plugin).
|
|
266
|
-
* @internal
|
|
267
|
-
*/
|
|
268
|
-
export declare interface _DependencyHandler<T extends _Dependency> {
|
|
269
|
-
/** Check if dependency is satisfied */
|
|
270
|
-
check(dep: T): Promise<_CheckResult>;
|
|
271
|
-
/** Check for conflicts with existing state */
|
|
272
|
-
checkConflict(dep: T): Promise<_ConflictResult>;
|
|
273
|
-
/** Add the dependency (update package.json for npm, noop for stripe cli) */
|
|
274
|
-
add(dep: T): Promise<{
|
|
275
|
-
action: 'add' | 'update';
|
|
276
|
-
message: string;
|
|
277
|
-
}>;
|
|
278
|
-
/** Run actual install (npm install for npm deps, stripe plugin install for cli) */
|
|
279
|
-
install(deps: T[]): Promise<void>;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Orchestrates dependency analysis and installation across all dependency types.
|
|
284
|
-
* @internal
|
|
285
|
-
*/
|
|
286
|
-
export declare class _DependencyManager {
|
|
287
|
-
private readonly cwd;
|
|
288
|
-
private readonly stripeConfigDir;
|
|
289
|
-
private readonly quiet;
|
|
290
|
-
private readonly context;
|
|
291
|
-
private readonly npmHandler;
|
|
292
|
-
private readonly devNpmHandler;
|
|
293
|
-
private readonly stripeCliPluginHandler;
|
|
294
|
-
/** Internal state: pending changes indexed by dependency key */
|
|
295
|
-
private pendingChanges;
|
|
296
|
-
/** Whether commit() has been called */
|
|
297
|
-
private committed;
|
|
298
|
-
constructor(options?: _DependencyManagerOptions);
|
|
299
|
-
/**
|
|
300
|
-
* Analyze dependencies and accumulate changes.
|
|
301
|
-
* Can be called multiple times before commit().
|
|
302
|
-
* Returns the changes for this specific call.
|
|
303
|
-
*/
|
|
304
|
-
ensureDependencies(input: _EnsureDependenciesInput): Promise<_PendingChange[]>;
|
|
305
|
-
/**
|
|
306
|
-
* Resolve a conflict by marking it for force install.
|
|
307
|
-
* Throws if the dependency is not in conflict state.
|
|
308
|
-
*/
|
|
309
|
-
resolveConflict(dep: _Dependency): void;
|
|
310
|
-
/**
|
|
311
|
-
* Get all pending changes (accumulated across all ensureDependencies calls).
|
|
312
|
-
*/
|
|
313
|
-
getPendingChanges(): _PendingChange[];
|
|
314
|
-
/**
|
|
315
|
-
* Commit all accumulated changes.
|
|
316
|
-
* - For npm deps: updates package.json, optionally runs package manager install
|
|
317
|
-
* - For Stripe CLI deps: always installs (no separate add step)
|
|
318
|
-
*
|
|
319
|
-
* @param options - Commit options. `options.runInstall`: if true, run package manager install for npm deps (default: true)
|
|
320
|
-
* @returns Summary of changes made
|
|
321
|
-
* @throws If called more than once
|
|
322
|
-
*/
|
|
323
|
-
commit(options?: _CommitOptions): Promise<_CommitResult>;
|
|
324
|
-
private analyzeDependency;
|
|
325
|
-
private getHandler;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Options for constructing a dependency manager.
|
|
330
|
-
* @internal
|
|
331
|
-
*/
|
|
332
|
-
export declare interface _DependencyManagerOptions {
|
|
333
|
-
/** Working directory (defaults to process.cwd()) */
|
|
334
|
-
cwd?: string;
|
|
335
|
-
/** Path to Stripe config directory (defaults to ~/.config/stripe) */
|
|
336
|
-
stripeConfigDir?: string;
|
|
337
|
-
/** Whether to suppress console output */
|
|
338
|
-
quiet?: boolean;
|
|
339
|
-
/** CLI context for user-facing output */
|
|
340
|
-
context?: _CliContext;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Detect the package manager used in the workspace by looking for lockfiles.
|
|
345
|
-
* @internal
|
|
346
|
-
*/
|
|
347
|
-
export declare function _detectPackageManager(cwd: string): _PackageManager;
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Create a dev npm dependency descriptor.
|
|
351
|
-
* @internal
|
|
352
|
-
*/
|
|
353
|
-
export declare function _devNpmDep(name: string, version: string): _DevNpmDependency;
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* A dev npm dependency to add to `devDependencies` in package.json.
|
|
357
|
-
* @internal
|
|
358
|
-
*/
|
|
359
|
-
export declare interface _DevNpmDependency {
|
|
360
|
-
/** Discriminant tag identifying this as a dev npm dependency. */
|
|
361
|
-
type: 'dev-npm';
|
|
362
|
-
/** npm package name. */
|
|
363
|
-
name: string;
|
|
364
|
-
/** Semver version range. */
|
|
365
|
-
version: string;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Authentication configuration for an endpoint.
|
|
370
|
-
* @internal
|
|
371
|
-
*/
|
|
372
|
-
export declare interface _EndpointAuth {
|
|
373
|
-
/** The type of authentication. */
|
|
374
|
-
type: 'bearer_token' | 'header';
|
|
375
|
-
/** The name of the secret containing the authentication credential. */
|
|
376
|
-
secret_name: string;
|
|
377
|
-
/** The name of the header to use for authentication (required when type is 'header'). */
|
|
378
|
-
header_name?: string;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Configuration for a single endpoint environment (live, test, managed_sandbox).
|
|
383
|
-
* @internal
|
|
384
|
-
*/
|
|
385
|
-
export declare interface _EndpointDefinition {
|
|
386
|
-
/** The HTTPS URL of the endpoint. */
|
|
387
|
-
url?: string;
|
|
388
|
-
/** The purpose of the endpoint. */
|
|
389
|
-
purpose?: string;
|
|
390
|
-
/** Authentication configuration. */
|
|
391
|
-
auth?: _EndpointAuth;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Input for requesting dependency installation.
|
|
396
|
-
* @internal
|
|
397
|
-
*/
|
|
398
|
-
export declare interface _EnsureDependenciesInput {
|
|
399
|
-
/** Dependencies that must be present. */
|
|
400
|
-
required: _Dependency[];
|
|
401
|
-
/** Dependencies that are preferred but not required. */
|
|
402
|
-
optional?: _Dependency[];
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Extension configuration for stripe-app.yaml
|
|
407
|
-
* @internal
|
|
408
|
-
*/
|
|
409
|
-
export declare interface _ExtensionConfig {
|
|
410
|
-
/** Extension identifier (e.g., `username.my-ext`). */
|
|
411
|
-
id: string;
|
|
412
|
-
/** Human-readable extension name. */
|
|
413
|
-
name: string;
|
|
414
|
-
/** Extension interface ID (e.g., `com.stripe.billing.bill`). */
|
|
415
|
-
interface_id: string;
|
|
416
|
-
/** Extension version string. */
|
|
417
|
-
version: string;
|
|
418
|
-
/** Developer-defined description for the extension (max 300 chars). */
|
|
419
|
-
description?: string;
|
|
420
|
-
/** Stripe API version to use for this extension (e.g., `2024-06-05`). */
|
|
421
|
-
stripe_version?: string;
|
|
422
|
-
/** Entry point script path, used by legacy script format. */
|
|
423
|
-
script_entry_point?: string;
|
|
424
|
-
/** Inline script definition (type + content path). */
|
|
425
|
-
script?: {
|
|
426
|
-
content: string;
|
|
427
|
-
type: string;
|
|
428
|
-
};
|
|
429
|
-
/** Required permissions for the extension. */
|
|
430
|
-
permissions: string[];
|
|
431
|
-
/** Method implementations keyed by method name. */
|
|
432
|
-
methods: Record<string, unknown>;
|
|
433
|
-
/** Optional configuration schemas for the extension. */
|
|
434
|
-
configuration?: _ExtensionConfiguration;
|
|
435
|
-
/** Remote function endpoints for the extension. */
|
|
436
|
-
endpoints?: {
|
|
437
|
-
id: string;
|
|
438
|
-
live?: _EndpointDefinition;
|
|
439
|
-
managed_sandbox?: _EndpointDefinition;
|
|
440
|
-
test?: _EndpointDefinition;
|
|
441
|
-
type: 'custom_http' | 'remote_function';
|
|
442
|
-
}[];
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Extension configuration schemas (JSON Schema for validation, UI Schema for rendering).
|
|
447
|
-
* @internal
|
|
448
|
-
*/
|
|
449
|
-
export declare interface _ExtensionConfiguration {
|
|
450
|
-
/** JSON Schema file for validating extension configuration. */
|
|
451
|
-
input_schema: _SchemaReference;
|
|
452
|
-
/** UI Schema file for rendering the configuration form. */
|
|
453
|
-
ui_schema: _SchemaReference;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* Static metadata for a single method on an extension template
|
|
458
|
-
* @internal
|
|
459
|
-
*/
|
|
460
|
-
export declare interface _ExtensionMethodInfo {
|
|
461
|
-
/** Implementation types supported by this method (e.g. 'script', 'remote-function') */
|
|
462
|
-
implementation_types: string[];
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* Parameters for extension template generation
|
|
467
|
-
* @internal
|
|
468
|
-
*/
|
|
469
|
-
export declare interface _ExtensionParams extends Record<string, unknown> {
|
|
470
|
-
/** Extension ID (validated to be safe for file paths and IDs) */
|
|
471
|
-
id: string;
|
|
472
|
-
/** Human-readable name for the extension */
|
|
473
|
-
name: string;
|
|
474
|
-
/** Package version (preserved from existing package.json, defaults to 0.0.1) */
|
|
475
|
-
version: string;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* Extension template - specialization of generic Template with a description
|
|
480
|
-
* @internal
|
|
481
|
-
*/
|
|
482
|
-
export declare interface _ExtensionTemplate extends _Template<_ExtensionParams, _ExtensionTemplateOutput> {
|
|
483
|
-
/** Short human-readable description of the extension interface */
|
|
484
|
-
description: string;
|
|
485
|
-
/** Whether this template is deprecated and should not be offered for new extensions */
|
|
486
|
-
deprecated?: boolean;
|
|
487
|
-
/** Whether this template is hidden from `stripe generate` (used only by the build pipeline) */
|
|
488
|
-
hidden?: boolean;
|
|
489
|
-
/** Static metadata for each method — implementation types supported per method */
|
|
490
|
-
methods: Record<string, _ExtensionMethodInfo>;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* Summary info for a registered extension template
|
|
495
|
-
* @internal
|
|
496
|
-
*/
|
|
497
|
-
export declare interface _ExtensionTemplateInfo {
|
|
498
|
-
/** Template key (the extension interface ID) */
|
|
499
|
-
key: string;
|
|
500
|
-
/** Short human-readable description */
|
|
501
|
-
description: string;
|
|
502
|
-
/** Whether this template is deprecated */
|
|
503
|
-
deprecated: boolean;
|
|
504
|
-
/** Whether this template is hidden from user-facing generators */
|
|
505
|
-
hidden: boolean;
|
|
506
|
-
/** Static metadata for each method — implementation types supported per method */
|
|
507
|
-
methods: Record<string, _ExtensionMethodInfo>;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* Extension template manager
|
|
512
|
-
* Specialized TemplateManager for extension generation
|
|
513
|
-
* @internal
|
|
514
|
-
*/
|
|
515
|
-
export declare class _ExtensionTemplateManager extends _TemplateManager<_ExtensionParams, _ExtensionTemplateOutput, _ExtensionTemplate> {
|
|
516
|
-
/**
|
|
517
|
-
* Get summary info for all registered extension templates
|
|
518
|
-
*/
|
|
519
|
-
getTemplateInfo(): _ExtensionTemplateInfo[];
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* Output from extension template generation
|
|
524
|
-
* @internal
|
|
525
|
-
*/
|
|
526
|
-
export declare interface _ExtensionTemplateOutput extends _TemplateOutput {
|
|
527
|
-
/** Methods configuration for stripe-app.yaml */
|
|
528
|
-
methods: Record<string, unknown>;
|
|
529
|
-
/** Dependencies required by the extension */
|
|
530
|
-
dependencies?: {
|
|
531
|
-
dev?: _DevNpmDependency[];
|
|
532
|
-
runtime?: _NpmDependency[];
|
|
533
|
-
};
|
|
534
|
-
/** Post-generation hooks to run after files are generated and dependencies installed */
|
|
535
|
-
postGenerationHooks?: _PostGenerationHook[];
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* Result of writing files
|
|
540
|
-
* @internal
|
|
541
|
-
*/
|
|
542
|
-
export declare interface _FileWriteResult {
|
|
543
|
-
/**
|
|
544
|
-
* Paths of files that were successfully written (relative to cwd)
|
|
545
|
-
* Includes both newly created files and overwritten files
|
|
546
|
-
*/
|
|
547
|
-
written: string[];
|
|
548
|
-
/**
|
|
549
|
-
* Paths of all files that already existed before the operation (relative to cwd)
|
|
550
|
-
* Always populated when files exist, regardless of whether they were overwritten
|
|
551
|
-
*/
|
|
552
|
-
existing: string[];
|
|
553
|
-
/**
|
|
554
|
-
* Whether the entire operation was skipped due to overwrite='abort-if-existing' with existing files
|
|
555
|
-
* True only when overwrite='abort-if-existing' and files exist (all-or-nothing behavior)
|
|
556
|
-
* False for all other modes including interactive (even if user skips all files)
|
|
557
|
-
*/
|
|
558
|
-
skipped: boolean;
|
|
559
|
-
/**
|
|
560
|
-
* Whether the user aborted the operation during interactive prompting
|
|
561
|
-
* True only when user chose 'quit' during interactive mode
|
|
562
|
-
* Caller should stop further processing (dependencies, hooks, etc.)
|
|
563
|
-
*/
|
|
564
|
-
aborted: boolean;
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* Options for writing generated files
|
|
569
|
-
* @internal
|
|
570
|
-
*/
|
|
571
|
-
export declare interface _FileWriterOptions {
|
|
572
|
-
/**
|
|
573
|
-
* Working directory to write files relative to
|
|
574
|
-
* Defaults to process.cwd()
|
|
575
|
-
*/
|
|
576
|
-
cwd?: string;
|
|
577
|
-
/**
|
|
578
|
-
* How to handle existing files:
|
|
579
|
-
* - 'overwrite-all': Overwrite all existing files
|
|
580
|
-
* - 'abort-if-existing': Refuse to write ANY files if ANY already exist (all-or-nothing)
|
|
581
|
-
* - 'if-missing': Skip individual files that exist, write only missing files
|
|
582
|
-
* - function: Prompt before overwriting each file (interactive ask mode)
|
|
583
|
-
* Defaults to 'abort-if-existing'
|
|
584
|
-
*/
|
|
585
|
-
write?: _WriteMode;
|
|
586
|
-
/**
|
|
587
|
-
* Callback invoked after a file is successfully written
|
|
588
|
-
* @param file - The file that was written
|
|
589
|
-
* @param wasOverwrite - True if file existed and was overwritten, false if newly created
|
|
590
|
-
*/
|
|
591
|
-
onFileWritten?: (file: _GeneratedFile, wasOverwrite: boolean) => void;
|
|
592
|
-
/**
|
|
593
|
-
* Callback invoked when a file already exists and is skipped
|
|
594
|
-
* @param file - The file that was skipped
|
|
595
|
-
*/
|
|
596
|
-
onFileSkipped?: (file: _GeneratedFile) => void;
|
|
597
|
-
/**
|
|
598
|
-
* Callback invoked when a file already exists with identical content
|
|
599
|
-
* @param file - The file that is identical
|
|
600
|
-
*/
|
|
601
|
-
onFileIdentical?: (file: _GeneratedFile) => void;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* Default TemplateFS instance rooted at templates/
|
|
606
|
-
*
|
|
607
|
-
* ESM: Uses filesystem implementation (reads from templates/ directory)
|
|
608
|
-
* CJS: This entire file is replaced with in-memory implementation
|
|
609
|
-
* @internal
|
|
610
|
-
*/
|
|
611
|
-
export declare const _fs: _TemplateFS;
|
|
612
|
-
|
|
613
|
-
/**
|
|
614
|
-
* Core generic types for the template system
|
|
615
|
-
*
|
|
616
|
-
* This module provides the foundation for a flexible, type-safe template system
|
|
617
|
-
* that can be specialized for different use cases (extensions, custom objects, etc.)
|
|
618
|
-
*/
|
|
619
|
-
/**
|
|
620
|
-
* Represents a single generated file
|
|
621
|
-
* @internal
|
|
622
|
-
*/
|
|
623
|
-
export declare interface _GeneratedFile {
|
|
624
|
-
/**
|
|
625
|
-
* Path to the file relative to project root
|
|
626
|
-
* Example: "extensions/my-extension/src/index.ts"
|
|
627
|
-
*/
|
|
628
|
-
path: string;
|
|
629
|
-
/**
|
|
630
|
-
* Content of the file
|
|
631
|
-
*/
|
|
632
|
-
content: string;
|
|
633
|
-
/**
|
|
634
|
-
* Never overwrite this file, even if --force specified.
|
|
635
|
-
*/
|
|
636
|
-
precious?: boolean;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
/**
|
|
640
|
-
* Manages stripe-app.json (V1) manifest file operations
|
|
641
|
-
*
|
|
642
|
-
* Capabilities:
|
|
643
|
-
* - Custom objects (add, remove, has, get)
|
|
644
|
-
* - App metadata (id, name)
|
|
645
|
-
*
|
|
646
|
-
* @example
|
|
647
|
-
* ```ts
|
|
648
|
-
* const manifest = await ManifestV1.load('./stripe-app.json')
|
|
649
|
-
* manifest.addCustomObject({ filePath: 'src/device.d.ts', className: 'Device' })
|
|
650
|
-
* await manifest.save()
|
|
651
|
-
* ```
|
|
652
|
-
* @internal
|
|
653
|
-
*/
|
|
654
|
-
export declare class _ManifestV1 {
|
|
655
|
-
private readonly filePath;
|
|
656
|
-
private data;
|
|
657
|
-
private constructor();
|
|
658
|
-
/**
|
|
659
|
-
* Load stripe-app.json from disk
|
|
660
|
-
* @param filePath - Path to stripe-app.json
|
|
661
|
-
* @throws Error if file is invalid or cannot be read
|
|
662
|
-
*/
|
|
663
|
-
static load(filePath: string): _ManifestV1;
|
|
664
|
-
/**
|
|
665
|
-
* Get the app ID from the manifest
|
|
666
|
-
*/
|
|
667
|
-
getAppId(): string;
|
|
668
|
-
/**
|
|
669
|
-
* Get the app name from the manifest
|
|
670
|
-
*/
|
|
671
|
-
getAppName(): string;
|
|
672
|
-
/**
|
|
673
|
-
* Get all custom objects as structured entries
|
|
674
|
-
*/
|
|
675
|
-
getCustomObjects(): _CustomObjectEntry[];
|
|
676
|
-
/**
|
|
677
|
-
* Check if a custom object entry exists in the manifest
|
|
678
|
-
*/
|
|
679
|
-
hasCustomObject(entry: _CustomObjectEntry): boolean;
|
|
680
|
-
/**
|
|
681
|
-
* Add a custom object entry to the manifest
|
|
682
|
-
* Does nothing if entry already exists
|
|
683
|
-
* @returns true if entry was added, false if it already existed
|
|
684
|
-
*/
|
|
685
|
-
addCustomObject(entry: _CustomObjectEntry): boolean;
|
|
686
|
-
/**
|
|
687
|
-
* Remove a custom object entry from the manifest
|
|
688
|
-
* @returns true if entry was removed, false if it didn't exist
|
|
689
|
-
*/
|
|
690
|
-
removeCustomObject(entry: _CustomObjectEntry): boolean;
|
|
691
|
-
/**
|
|
692
|
-
* Get the raw manifest data (for reading other fields)
|
|
693
|
-
*/
|
|
694
|
-
getRawData(): Readonly<_ManifestV1Data>;
|
|
695
|
-
/**
|
|
696
|
-
* Save changes back to disk
|
|
697
|
-
*/
|
|
698
|
-
save(): void;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* V1 manifest structure (stripe-app.json)
|
|
703
|
-
* @internal
|
|
704
|
-
*/
|
|
705
|
-
export declare interface _ManifestV1Data {
|
|
706
|
-
/** The app identifier. */
|
|
707
|
-
id: string;
|
|
708
|
-
/** The app version string. */
|
|
709
|
-
version: string;
|
|
710
|
-
/** The app display name. */
|
|
711
|
-
name: string;
|
|
712
|
-
/** List of custom object entries in `path#ClassName` format. */
|
|
713
|
-
exported_custom_objects?: string[];
|
|
714
|
-
/** Additional manifest fields. */
|
|
715
|
-
[key: string]: unknown;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
/**
|
|
719
|
-
* Manages stripe-app.yaml (V2) manifest file operations
|
|
720
|
-
*
|
|
721
|
-
* Capabilities:
|
|
722
|
-
* - Extensions (add, update, get)
|
|
723
|
-
* - App metadata (id, name)
|
|
724
|
-
*
|
|
725
|
-
* @example
|
|
726
|
-
* ```ts
|
|
727
|
-
* const manifest = await _ManifestV2.load('./stripe-app.yaml')
|
|
728
|
-
* manifest.addOrUpdateExtension({
|
|
729
|
-
* id: 'username.my-ext',
|
|
730
|
-
* name: 'my-ext',
|
|
731
|
-
* interfaceId: 'com.stripe.test',
|
|
732
|
-
* version: '0.0.1',
|
|
733
|
-
* scriptEntryPoint: 'scripts/my-ext/index.ts',
|
|
734
|
-
* permissions: [],
|
|
735
|
-
* methods: { my_run: { implementation_type: 'script' } }
|
|
736
|
-
* })
|
|
737
|
-
* await manifest.save()
|
|
738
|
-
* ```
|
|
739
|
-
* @internal
|
|
740
|
-
*/
|
|
741
|
-
export declare class _ManifestV2 {
|
|
742
|
-
private readonly filePath;
|
|
743
|
-
private data;
|
|
744
|
-
private constructor();
|
|
745
|
-
/**
|
|
746
|
-
* Load stripe-app.yaml from disk
|
|
747
|
-
* @param filePath - Path to stripe-app.yaml
|
|
748
|
-
* @throws Error if file is invalid or cannot be read
|
|
749
|
-
*/
|
|
750
|
-
static load(filePath: string): Promise<_ManifestV2>;
|
|
751
|
-
/**
|
|
752
|
-
* Get the app ID from the manifest
|
|
753
|
-
*/
|
|
754
|
-
getAppId(): string | undefined;
|
|
755
|
-
/**
|
|
756
|
-
* Get the app name from the manifest
|
|
757
|
-
*/
|
|
758
|
-
getAppName(): string | undefined;
|
|
759
|
-
/**
|
|
760
|
-
* Get all custom object definitions, parsed into internal format.
|
|
761
|
-
* Entries are guaranteed structurally valid by load-time validation.
|
|
762
|
-
*/
|
|
763
|
-
getCustomObjects(): _CustomObjectDefinition[];
|
|
764
|
-
/**
|
|
765
|
-
* Check if a custom object exists by id
|
|
766
|
-
*/
|
|
767
|
-
hasCustomObject(id: string): boolean;
|
|
768
|
-
/**
|
|
769
|
-
* Add a custom object definition.
|
|
770
|
-
*
|
|
771
|
-
* Identity is keyed on `id` alone. The export name is derived via
|
|
772
|
-
* `_toPascalCase(id)` at read time, so `id` should be valid snake_case
|
|
773
|
-
* (e.g., "device", "loyalty_card", "http_request").
|
|
774
|
-
*
|
|
775
|
-
* @param id - Object identifier (e.g., "device", "loyalty_card")
|
|
776
|
-
* @param content - Path to the definition file (e.g., "src/device.object.ts")
|
|
777
|
-
* @param type - Specification type, defaults to "typescript"
|
|
778
|
-
* @returns true if added, false if already exists
|
|
779
|
-
*/
|
|
780
|
-
addCustomObject(id: string, content: string, type?: string): boolean;
|
|
781
|
-
/**
|
|
782
|
-
* Remove a custom object definition by id
|
|
783
|
-
* @param id - Object identifier to remove
|
|
784
|
-
* @returns true if removed, false if not found
|
|
785
|
-
*/
|
|
786
|
-
removeCustomObject(id: string): boolean;
|
|
787
|
-
/**
|
|
788
|
-
* Add a new extension or update an existing one by ID
|
|
789
|
-
* If an extension with the provided ID exists, it will be replaced entirely
|
|
790
|
-
* @param extension - Extension configuration with all required fields including id
|
|
791
|
-
* @returns The extension ID
|
|
792
|
-
*/
|
|
793
|
-
addOrUpdateExtension(extension: _ExtensionConfig): string;
|
|
794
|
-
/**
|
|
795
|
-
* Get a read-only view of all extensions
|
|
796
|
-
*/
|
|
797
|
-
getExtensions(): readonly Readonly<_ExtensionConfig>[];
|
|
798
|
-
/**
|
|
799
|
-
* Get the raw manifest data (for reading other fields)
|
|
800
|
-
*/
|
|
801
|
-
getRawData(): Readonly<_ManifestV2Data>;
|
|
802
|
-
/**
|
|
803
|
-
* Save changes back to disk
|
|
804
|
-
* @throws Error if file cannot be written
|
|
805
|
-
*/
|
|
806
|
-
save(): Promise<void>;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
/**
|
|
810
|
-
* V2 manifest structure (stripe-app.yaml)
|
|
811
|
-
* @internal
|
|
812
|
-
*/
|
|
813
|
-
export declare interface _ManifestV2Data {
|
|
814
|
-
/** The app identifier. */
|
|
815
|
-
id: string;
|
|
816
|
-
/** The app display name. */
|
|
817
|
-
name: string;
|
|
818
|
-
/** The app version string. */
|
|
819
|
-
version: string;
|
|
820
|
-
/** Registered extension configurations. */
|
|
821
|
-
extensions?: _ExtensionConfig[];
|
|
822
|
-
/** Custom object definitions block. */
|
|
823
|
-
custom_object_definitions?: _CustomObjectDefinitionsBlock;
|
|
824
|
-
/** Additional manifest fields. */
|
|
825
|
-
[key: string]: unknown;
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
/**
|
|
829
|
-
* Manifest version types
|
|
830
|
-
* @internal
|
|
831
|
-
*/
|
|
832
|
-
export declare type _ManifestVersion = 'v1' | 'v2';
|
|
833
|
-
|
|
834
|
-
/**
|
|
835
|
-
* Create a runtime npm dependency descriptor.
|
|
836
|
-
* @internal
|
|
837
|
-
*/
|
|
838
|
-
export declare function _npmDep(name: string, version: string): _NpmDependency;
|
|
839
|
-
|
|
840
|
-
/**
|
|
841
|
-
* A runtime npm dependency to add to `dependencies` in package.json.
|
|
842
|
-
* @internal
|
|
843
|
-
*/
|
|
844
|
-
export declare interface _NpmDependency {
|
|
845
|
-
/** Discriminant tag identifying this as a runtime npm dependency. */
|
|
846
|
-
type: 'npm';
|
|
847
|
-
/** npm package name. */
|
|
848
|
-
name: string;
|
|
849
|
-
/** Semver version range. */
|
|
850
|
-
version: string;
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
/**
|
|
854
|
-
* Handles npm and dev-npm dependency installation via package.json updates.
|
|
855
|
-
* @internal
|
|
856
|
-
*/
|
|
857
|
-
export declare class _NpmDependencyHandler implements _DependencyHandler<_NpmDependency | _DevNpmDependency> {
|
|
858
|
-
private readonly cwd;
|
|
859
|
-
private readonly quiet;
|
|
860
|
-
private readonly devDependencies;
|
|
861
|
-
private readonly context;
|
|
862
|
-
constructor(options: _NpmHandlerOptions);
|
|
863
|
-
private get dependencyKey();
|
|
864
|
-
private get dependencyLabel();
|
|
865
|
-
/** Check whether the npm dependency is already present in package.json. */
|
|
866
|
-
check(dep: _DevNpmDependency | _NpmDependency): Promise<_CheckResult>;
|
|
867
|
-
/** Check whether the requested version conflicts with the currently installed version. */
|
|
868
|
-
checkConflict(dep: _DevNpmDependency | _NpmDependency): Promise<_ConflictResult>;
|
|
869
|
-
/** Add or update the npm dependency in package.json. */
|
|
870
|
-
add(dep: _DevNpmDependency | _NpmDependency): Promise<{
|
|
871
|
-
action: 'add' | 'update';
|
|
872
|
-
message: string;
|
|
873
|
-
}>;
|
|
874
|
-
/** Run the package manager install command in the working directory. */
|
|
875
|
-
install(_deps: (_DevNpmDependency | _NpmDependency)[]): Promise<void>;
|
|
876
|
-
private versionsCompatible;
|
|
877
|
-
private extractMajorVersion;
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
/**
|
|
881
|
-
* Options for constructing an npm dependency handler.
|
|
882
|
-
* @internal
|
|
883
|
-
*/
|
|
884
|
-
export declare interface _NpmHandlerOptions {
|
|
885
|
-
/** Working directory containing the target package.json. */
|
|
886
|
-
cwd: string;
|
|
887
|
-
/** Whether to suppress console output. */
|
|
888
|
-
quiet: boolean;
|
|
889
|
-
/** If true, manage devDependencies; otherwise manage dependencies. */
|
|
890
|
-
devDependencies?: boolean;
|
|
891
|
-
/** CLI context for user-facing output. */
|
|
892
|
-
context?: _CliContext;
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
/**
|
|
896
|
-
* User decision when prompted about overwriting a file
|
|
897
|
-
* @internal
|
|
898
|
-
*/
|
|
899
|
-
export declare type _OverwriteDecision = 'abort' | 'overwrite-all' | 'overwrite' | 'skip';
|
|
900
|
-
|
|
901
|
-
/**
|
|
902
|
-
* Callback function for prompting about file overwrites
|
|
903
|
-
* @param path - Relative path to the file that would be overwritten
|
|
904
|
-
* @param cwd - Working directory (for resolving the path)
|
|
905
|
-
* @param newContent - Content of the file that would be written
|
|
906
|
-
* @returns Promise resolving to user's decision
|
|
907
|
-
* @internal
|
|
908
|
-
*/
|
|
909
|
-
export declare type _OverwritePromptCallback = (path: string, cwd: string, newContent: string) => Promise<_OverwriteDecision>;
|
|
910
|
-
|
|
911
|
-
/**
|
|
912
|
-
* Package manager detected in the workspace.
|
|
913
|
-
* @internal
|
|
914
|
-
*/
|
|
915
|
-
export declare type _PackageManager = 'npm' | 'pnpm' | 'yarn';
|
|
916
|
-
|
|
917
|
-
/**
|
|
918
|
-
* Package metadata (id, name, version)
|
|
919
|
-
* @internal - Exported for testing only
|
|
920
|
-
*/
|
|
921
|
-
export declare interface _PackageMetadata {
|
|
922
|
-
/** The package identifier (from package.json `name`). */
|
|
923
|
-
id: string;
|
|
924
|
-
/** Human-readable display name (from package.json `description`). */
|
|
925
|
-
name: string;
|
|
926
|
-
/** Package version string (from package.json `version`). */
|
|
927
|
-
version: string;
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
/**
|
|
931
|
-
* A pending dependency change accumulated by the dependency manager before commit.
|
|
932
|
-
* @internal
|
|
933
|
-
*/
|
|
934
|
-
export declare interface _PendingChange {
|
|
935
|
-
/** The dependency this change applies to. */
|
|
936
|
-
dependency: _Dependency;
|
|
937
|
-
/** The action that will be taken for this dependency. */
|
|
938
|
-
action: _DependencyAction;
|
|
939
|
-
/** Human-readable message describing the pending change. */
|
|
940
|
-
message: string;
|
|
941
|
-
/** The previously installed version, if an update is involved. */
|
|
942
|
-
previousVersion?: string;
|
|
943
|
-
/** Conflict details when action is 'conflict'. */
|
|
944
|
-
conflict?: _ConflictResult;
|
|
945
|
-
/** Whether conflict has been resolved (force install) */
|
|
946
|
-
conflictResolved?: boolean;
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
/**
|
|
950
|
-
* Post-generation hook configuration
|
|
951
|
-
* Either `script` (run via `pnpm run`) or `exec` (run via `pnpm exec`)
|
|
952
|
-
* @internal
|
|
953
|
-
*/
|
|
954
|
-
export declare type _PostGenerationHook = {
|
|
955
|
-
description?: string;
|
|
956
|
-
exec: string;
|
|
957
|
-
} | {
|
|
958
|
-
description?: string;
|
|
959
|
-
script: string;
|
|
960
|
-
};
|
|
961
|
-
|
|
962
|
-
/**
|
|
963
|
-
* Simple text-based prompt for overwrite decisions
|
|
964
|
-
* Uses single-keypress input in interactive terminals (no Enter required)
|
|
965
|
-
* Falls back to line-based input in non-interactive environments (tests, CI)
|
|
966
|
-
*
|
|
967
|
-
* @param filePath - Path to the file that would be overwritten
|
|
968
|
-
* @returns Promise resolving to user's decision
|
|
969
|
-
* @internal
|
|
970
|
-
*/
|
|
971
|
-
export declare function _promptOverwrite(filePath: string): Promise<_OverwriteDecision>;
|
|
972
|
-
|
|
973
|
-
/**
|
|
974
|
-
* Regenerate workspace files from templates
|
|
975
|
-
*
|
|
976
|
-
* @param options - Regeneration options
|
|
977
|
-
* @param services - Injectable collaborators (defaults to real implementations)
|
|
978
|
-
* @param context - CLI context for user-facing output. Defaults to a new context with standard stdout/stderr streams.
|
|
979
|
-
*
|
|
980
|
-
* @example
|
|
981
|
-
* ```typescript
|
|
982
|
-
* // Regenerate root workspace (scenario 1)
|
|
983
|
-
* await regenAppProjectWorkspace({ packageDir: '.' });
|
|
984
|
-
*
|
|
985
|
-
* // Create new extension (scenario 2)
|
|
986
|
-
* await regenAppProjectWorkspace({
|
|
987
|
-
* templateId: 'core.workflows.custom_action',
|
|
988
|
-
* workspaceId: 'my-ext',
|
|
989
|
-
* });
|
|
990
|
-
*
|
|
991
|
-
* // Regenerate extension from its directory (scenario 3)
|
|
992
|
-
* await regenAppProjectWorkspace({
|
|
993
|
-
* root: '../..',
|
|
994
|
-
* packageDir: '.',
|
|
995
|
-
* templateId: 'core.workflows.custom_action',
|
|
996
|
-
* });
|
|
997
|
-
*
|
|
998
|
-
* // Regenerate extension from project root (scenario 4)
|
|
999
|
-
* await regenAppProjectWorkspace({
|
|
1000
|
-
* packageDir: 'extensions/my-ext',
|
|
1001
|
-
* templateId: 'core.workflows.custom_action',
|
|
1002
|
-
* });
|
|
1003
|
-
*
|
|
1004
|
-
* // Ensure custom-objects workspace (scenario 5)
|
|
1005
|
-
* await regenAppProjectWorkspace({
|
|
1006
|
-
* templateId: 'custom-objects',
|
|
1007
|
-
* workspaceId: 'custom-objects',
|
|
1008
|
-
* });
|
|
1009
|
-
* ```
|
|
1010
|
-
* @internal
|
|
1011
|
-
*/
|
|
1012
|
-
export declare function _regenAppProjectWorkspace(options: _RegenWorkspaceOptions, services?: _WorkspaceServices, context?: _CliContext): Promise<void>;
|
|
1013
|
-
|
|
1014
|
-
/**
|
|
1015
|
-
* Options for regenerating a workspace from templates.
|
|
1016
|
-
* @internal
|
|
1017
|
-
*/
|
|
1018
|
-
export declare type _RegenWorkspaceOptions = z.infer<typeof _regenWorkspaceOptionsSchema>;
|
|
1019
|
-
|
|
1020
|
-
/**
|
|
1021
|
-
* Options for workspace regeneration
|
|
1022
|
-
* @internal
|
|
1023
|
-
*/
|
|
1024
|
-
export declare const _regenWorkspaceOptionsSchema: z.ZodObject<{
|
|
1025
|
-
force: z.ZodOptional<z.ZodBoolean>;
|
|
1026
|
-
implementationType: z.ZodOptional<z.ZodEnum<{
|
|
1027
|
-
"remote-function": "remote-function";
|
|
1028
|
-
script: "script";
|
|
1029
|
-
}>>;
|
|
1030
|
-
name: z.ZodOptional<z.ZodString>;
|
|
1031
|
-
packageDir: z.ZodOptional<z.ZodString>;
|
|
1032
|
-
root: z.ZodOptional<z.ZodString>;
|
|
1033
|
-
skipDependencies: z.ZodOptional<z.ZodBoolean>;
|
|
1034
|
-
skipHooks: z.ZodOptional<z.ZodBoolean>;
|
|
1035
|
-
templateId: z.ZodOptional<z.ZodString>;
|
|
1036
|
-
workspaceId: z.ZodOptional<z.ZodString>;
|
|
1037
|
-
workspaceName: z.ZodOptional<z.ZodString>;
|
|
1038
|
-
}, z.core.$strip>;
|
|
1039
|
-
|
|
1040
|
-
/**
|
|
1041
|
-
* Resolve package ID, name, and version from options or package.json
|
|
1042
|
-
*
|
|
1043
|
-
* @param providedId - ID from options
|
|
1044
|
-
* @param providedName - Name from options (overrides package.json)
|
|
1045
|
-
* @param packageDir - Directory containing package.json, or undefined to skip reading
|
|
1046
|
-
* @returns Object with id, name, and version
|
|
1047
|
-
* @throws Error if ID cannot be determined, or if both providedId and package.json ID
|
|
1048
|
-
* exist and differ
|
|
1049
|
-
* @internal - Exported for testing only
|
|
1050
|
-
*/
|
|
1051
|
-
export declare function _resolvePackageMetadata(providedId: string | undefined, providedName: string | undefined, packageDir: string | undefined): Promise<_PackageMetadata>;
|
|
1052
|
-
|
|
1053
|
-
/**
|
|
1054
|
-
* Root workspace template manager
|
|
1055
|
-
* Automatically selects filesystem or in-memory implementation
|
|
1056
|
-
* @internal
|
|
1057
|
-
*/
|
|
1058
|
-
export declare const _rootTemplateManager: _SingleTemplateManager<_RootWorkspaceParams, _RootWorkspaceOutput>;
|
|
1059
|
-
|
|
1060
|
-
/**
|
|
1061
|
-
* Output from root workspace template generation
|
|
1062
|
-
* @internal
|
|
1063
|
-
*/
|
|
1064
|
-
export declare interface _RootWorkspaceOutput extends _TemplateOutput {
|
|
1065
|
-
/** Dependencies to install after file generation. */
|
|
1066
|
-
dependencies?: {
|
|
1067
|
-
dev?: _DevNpmDependency[];
|
|
1068
|
-
runtime?: _NpmDependency[];
|
|
1069
|
-
};
|
|
1070
|
-
/** Hooks to run after dependencies are installed. */
|
|
1071
|
-
postGenerationHooks?: _PostGenerationHook[];
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
/**
|
|
1075
|
-
* Parameters for root workspace template generation
|
|
1076
|
-
* @internal
|
|
1077
|
-
*/
|
|
1078
|
-
export declare interface _RootWorkspaceParams extends Record<string, unknown> {
|
|
1079
|
-
/** The app identifier (package.json `name`). */
|
|
1080
|
-
appId: string;
|
|
1081
|
-
/** The app display name (package.json `description`). */
|
|
1082
|
-
appName: string;
|
|
1083
|
-
/** The app version string. */
|
|
1084
|
-
version: string;
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
/**
|
|
1088
|
-
* Root workspace template generator.
|
|
1089
|
-
*
|
|
1090
|
-
* Generates common configuration files for the monorepo root:
|
|
1091
|
-
* - .prettierrc (code formatting config)
|
|
1092
|
-
* - .prettierignore (files to ignore in formatting)
|
|
1093
|
-
*
|
|
1094
|
-
* @example
|
|
1095
|
-
* ```typescript
|
|
1096
|
-
* const output = rootWorkspaceTemplate.generate({}, context);
|
|
1097
|
-
* await writeFiles(output.files, '.', true);
|
|
1098
|
-
* ```
|
|
1099
|
-
* @internal
|
|
1100
|
-
*/
|
|
1101
|
-
export declare const _rootWorkspaceTemplate: _Template<_RootWorkspaceParams, _RootWorkspaceOutput>;
|
|
1102
|
-
|
|
1103
|
-
/**
|
|
1104
|
-
* A reference to a schema file in the project (type + relative path).
|
|
1105
|
-
*
|
|
1106
|
-
* Note: stripe-cli-apps-plugin is the authoritative representation of the
|
|
1107
|
-
* Stripe App manifest. Types here are a best-effort mirror.
|
|
1108
|
-
* @internal
|
|
1109
|
-
*/
|
|
1110
|
-
export declare interface _SchemaReference {
|
|
1111
|
-
/** The schema format. */
|
|
1112
|
-
type: 'json_schema' | 'jsonforms';
|
|
1113
|
-
/** Relative path to the schema file. Named `content` to match the manifest field. */
|
|
1114
|
-
content: string;
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
/**
|
|
1118
|
-
* Single template manager - no registry lookup needed
|
|
1119
|
-
* For commands that only have one template
|
|
1120
|
-
* @internal
|
|
1121
|
-
*/
|
|
1122
|
-
export declare class _SingleTemplateManager<TParams, TOutput extends _TemplateOutput = _TemplateOutput> {
|
|
1123
|
-
private readonly template;
|
|
1124
|
-
private readonly fs;
|
|
1125
|
-
/**
|
|
1126
|
-
* Create a new SingleTemplateManager
|
|
1127
|
-
* @param template - The single template to use
|
|
1128
|
-
* @param fs - Filesystem for template file reading
|
|
1129
|
-
*/
|
|
1130
|
-
constructor(template: _Template<TParams, TOutput>, fs: _TemplateFS);
|
|
1131
|
-
/**
|
|
1132
|
-
* Generate output from the template
|
|
1133
|
-
* @param params - Template parameters
|
|
1134
|
-
* @returns Template output
|
|
1135
|
-
*/
|
|
1136
|
-
generate(params: TParams): Promise<TOutput>;
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
/**
|
|
1140
|
-
* Unified interface for Stripe App manifest operations.
|
|
1141
|
-
*
|
|
1142
|
-
* This class provides an abstraction over both V1 (stripe-app.json) and V2 (stripe-app.yaml)
|
|
1143
|
-
* manifest formats, automatically detecting the version and delegating to the appropriate reader.
|
|
1144
|
-
*
|
|
1145
|
-
* Capabilities by version:
|
|
1146
|
-
* - V1 (JSON): Custom objects, app metadata
|
|
1147
|
-
* - V2 (YAML): Extensions, custom objects, app metadata
|
|
1148
|
-
*
|
|
1149
|
-
* @example
|
|
1150
|
-
* ```ts
|
|
1151
|
-
* const manifest = await _StripeAppManifest.load('./stripe-app.yaml')
|
|
1152
|
-
* manifest.addOrUpdateExtension({ ... })
|
|
1153
|
-
* await manifest.save()
|
|
1154
|
-
* ```
|
|
1155
|
-
* @internal
|
|
1156
|
-
*/
|
|
1157
|
-
export declare class _StripeAppManifest {
|
|
1158
|
-
private readonly manifestPath;
|
|
1159
|
-
private readonly version;
|
|
1160
|
-
private readonly v1;
|
|
1161
|
-
private readonly v2;
|
|
1162
|
-
private constructor();
|
|
1163
|
-
/**
|
|
1164
|
-
* Load a manifest file, automatically detecting the version.
|
|
1165
|
-
* @param manifestPath - Path to stripe-app.json or stripe-app.yaml
|
|
1166
|
-
* @returns Loaded manifest instance
|
|
1167
|
-
*/
|
|
1168
|
-
static load(manifestPath: string): Promise<_StripeAppManifest>;
|
|
1169
|
-
/**
|
|
1170
|
-
* Detect manifest version from file path.
|
|
1171
|
-
* TODO: Add content-based detection if needed.
|
|
1172
|
-
*/
|
|
1173
|
-
private static detectVersion;
|
|
1174
|
-
/**
|
|
1175
|
-
* Get the detected manifest version
|
|
1176
|
-
*/
|
|
1177
|
-
getVersion(): _ManifestVersion;
|
|
1178
|
-
/**
|
|
1179
|
-
* Get the manifest file path
|
|
1180
|
-
*/
|
|
1181
|
-
getManifestPath(): string;
|
|
1182
|
-
/**
|
|
1183
|
-
* Get the app ID from the manifest
|
|
1184
|
-
*/
|
|
1185
|
-
getAppId(): string | undefined;
|
|
1186
|
-
/**
|
|
1187
|
-
* Get the app name from the manifest
|
|
1188
|
-
*/
|
|
1189
|
-
getAppName(): string | undefined;
|
|
1190
|
-
/**
|
|
1191
|
-
* Get all custom objects from the manifest
|
|
1192
|
-
*/
|
|
1193
|
-
getCustomObjects(): _CustomObjectEntry[];
|
|
1194
|
-
/**
|
|
1195
|
-
* Check if a custom object entry exists in the manifest.
|
|
1196
|
-
*
|
|
1197
|
-
* **V2 note:** Identity is keyed on `_toSnakeCase(className)` alone — `filePath`
|
|
1198
|
-
* is not considered. Two entries with the same class name but different file
|
|
1199
|
-
* paths are treated as the same object. The `_toSnakeCase` → `_toPascalCase`
|
|
1200
|
-
* round-trip is lossless for typical class names but lossy for consecutive
|
|
1201
|
-
* uppercase (e.g., `HTTPClient` → `http_client` → `HttpClient`). The manifest
|
|
1202
|
-
* `id` field is the source of truth; see `_CustomObjectDefinitionYaml` docs.
|
|
1203
|
-
*/
|
|
1204
|
-
hasCustomObject(entry: _CustomObjectEntry): boolean;
|
|
1205
|
-
/**
|
|
1206
|
-
* Add a custom object entry to the manifest.
|
|
1207
|
-
*
|
|
1208
|
-
* **V2 note:** The manifest `id` is derived as `_toSnakeCase(className)` and
|
|
1209
|
-
* `filePath` is stored as the specification `content` path. Identity/dedup
|
|
1210
|
-
* is based on `id` alone — see `hasCustomObject` for details.
|
|
1211
|
-
*
|
|
1212
|
-
* @param entry - The custom object entry to add
|
|
1213
|
-
* @returns true if entry was added, false if it already existed
|
|
1214
|
-
*/
|
|
1215
|
-
addCustomObject(entry: _CustomObjectEntry): boolean;
|
|
1216
|
-
/**
|
|
1217
|
-
* Remove a custom object entry from the manifest.
|
|
1218
|
-
*
|
|
1219
|
-
* **V2 note:** Removal is keyed on `_toSnakeCase(className)` — `filePath` is
|
|
1220
|
-
* not considered. See `hasCustomObject` for identity semantics.
|
|
1221
|
-
*
|
|
1222
|
-
* @param entry - The custom object entry to remove
|
|
1223
|
-
* @returns true if entry was removed, false if it didn't exist
|
|
1224
|
-
*/
|
|
1225
|
-
removeCustomObject(entry: _CustomObjectEntry): boolean;
|
|
1226
|
-
/**
|
|
1227
|
-
* Get all extensions from the manifest
|
|
1228
|
-
* @throws Error if manifest version doesn't support extensions
|
|
1229
|
-
*/
|
|
1230
|
-
getExtensions(): readonly Readonly<_ExtensionConfig>[];
|
|
1231
|
-
/**
|
|
1232
|
-
* Add or update an extension in the manifest.
|
|
1233
|
-
* If an extension with the same ID exists, it will be replaced.
|
|
1234
|
-
*
|
|
1235
|
-
* @param config - Full extension configuration
|
|
1236
|
-
* @returns The extension ID
|
|
1237
|
-
* @throws Error if manifest version doesn't support extensions
|
|
1238
|
-
*/
|
|
1239
|
-
addOrUpdateExtension(config: _ExtensionConfig): string;
|
|
1240
|
-
/**
|
|
1241
|
-
* Save changes back to disk
|
|
1242
|
-
*/
|
|
1243
|
-
save(): Promise<void>;
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
/**
|
|
1247
|
-
* Create a Stripe CLI plugin dependency descriptor.
|
|
1248
|
-
* @internal
|
|
1249
|
-
*/
|
|
1250
|
-
export declare function _stripeCliPluginDep(name: string, minVersion?: string): _StripeCliPluginDependency;
|
|
1251
|
-
|
|
1252
|
-
/**
|
|
1253
|
-
* A Stripe CLI plugin dependency that must be installed via `stripe plugin install`.
|
|
1254
|
-
* @internal
|
|
1255
|
-
*/
|
|
1256
|
-
export declare interface _StripeCliPluginDependency {
|
|
1257
|
-
/** Discriminant tag identifying this as a Stripe CLI plugin dependency. */
|
|
1258
|
-
type: 'stripe-cli-plugin';
|
|
1259
|
-
/** Plugin shortname (e.g., `extensibility`). */
|
|
1260
|
-
name: string;
|
|
1261
|
-
/** Minimum required semver version of the plugin. */
|
|
1262
|
-
minVersion?: string;
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
/**
|
|
1266
|
-
* Handles Stripe CLI plugin installation via `stripe plugin install`.
|
|
1267
|
-
* @internal
|
|
1268
|
-
*/
|
|
1269
|
-
export declare class _StripeCliPluginHandler implements _DependencyHandler<_StripeCliPluginDependency> {
|
|
1270
|
-
private readonly stripeConfigDir;
|
|
1271
|
-
private readonly quiet;
|
|
1272
|
-
private readonly context;
|
|
1273
|
-
constructor(options: _StripeCliPluginHandlerOptions);
|
|
1274
|
-
/** Check whether the Stripe CLI plugin is installed and meets the minimum version. */
|
|
1275
|
-
check(dep: _StripeCliPluginDependency): Promise<_CheckResult>;
|
|
1276
|
-
/** Check whether the installed plugin version conflicts with the requested minimum. */
|
|
1277
|
-
checkConflict(dep: _StripeCliPluginDependency): Promise<_ConflictResult>;
|
|
1278
|
-
/** Stage a Stripe CLI plugin for installation; the actual install happens in `install`. */
|
|
1279
|
-
add(dep: _StripeCliPluginDependency): Promise<{
|
|
1280
|
-
action: 'add' | 'update';
|
|
1281
|
-
message: string;
|
|
1282
|
-
}>;
|
|
1283
|
-
/** Install Stripe CLI plugins using `stripe plugin install`. */
|
|
1284
|
-
install(deps: _StripeCliPluginDependency[]): Promise<void>;
|
|
1285
|
-
private findPluginInToml;
|
|
1286
|
-
/**
|
|
1287
|
-
* Check if installed version satisfies the required minimum version.
|
|
1288
|
-
*
|
|
1289
|
-
* Permissive policy: Non-semver versions (e.g., "local.build.dev", "dev", "canary-abc123")
|
|
1290
|
-
* always satisfy version requirements. This avoids forcing upgrades during local development
|
|
1291
|
-
* when developers are using locally built plugins.
|
|
1292
|
-
*
|
|
1293
|
-
* For valid semver versions, uses the semver library for proper semantic version comparison.
|
|
1294
|
-
*
|
|
1295
|
-
* @param installed - The installed version string
|
|
1296
|
-
* @param required - The required minimum version string
|
|
1297
|
-
* @returns true if installed version satisfies requirement
|
|
1298
|
-
*/
|
|
1299
|
-
private isVersionSatisfied;
|
|
1300
|
-
}
|
|
1301
|
-
|
|
1302
|
-
/**
|
|
1303
|
-
* Options for constructing a Stripe CLI plugin dependency handler.
|
|
1304
|
-
* @internal
|
|
1305
|
-
*/
|
|
1306
|
-
export declare interface _StripeCliPluginHandlerOptions {
|
|
1307
|
-
/** Path to the Stripe CLI config directory (e.g., `~/.config/stripe`). */
|
|
1308
|
-
stripeConfigDir: string;
|
|
1309
|
-
/** Whether to suppress console output. */
|
|
1310
|
-
quiet: boolean;
|
|
1311
|
-
/** CLI context for user-facing output. */
|
|
1312
|
-
context?: _CliContext;
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
|
-
/**
|
|
1316
|
-
* Template definition
|
|
1317
|
-
* Wraps a generate function with any associated metadata
|
|
1318
|
-
*
|
|
1319
|
-
* @typeParam TParams - Parameters for template generation
|
|
1320
|
-
* @typeParam TOutput - Output type (must extend TemplateOutput)
|
|
1321
|
-
* @internal
|
|
1322
|
-
*/
|
|
1323
|
-
export declare interface _Template<TParams, TOutput extends _TemplateOutput = _TemplateOutput> {
|
|
1324
|
-
/**
|
|
1325
|
-
* Generate files and other output from the template
|
|
1326
|
-
*/
|
|
1327
|
-
generate(params: TParams, context: _TemplateContext): Promise<TOutput> | TOutput;
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
/**
|
|
1331
|
-
* Context for template generation
|
|
1332
|
-
* Provides optional capabilities like file reading and user prompts
|
|
1333
|
-
* Templates can ignore this parameter if they don't need these features
|
|
1334
|
-
* @internal
|
|
1335
|
-
*/
|
|
1336
|
-
export declare interface _TemplateContext {
|
|
1337
|
-
/**
|
|
1338
|
-
* Filesystem abstraction for reading template files
|
|
1339
|
-
*/
|
|
1340
|
-
fs: _TemplateFS;
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
/**
|
|
1344
|
-
* Filesystem abstraction for template factories
|
|
1345
|
-
* @internal
|
|
1346
|
-
*/
|
|
1347
|
-
export declare interface _TemplateFS {
|
|
1348
|
-
/**
|
|
1349
|
-
* Read a text file relative to the templates directory
|
|
1350
|
-
*
|
|
1351
|
-
* Note: Only supports text files. Binary files are not supported by the
|
|
1352
|
-
* current implementation (template content is embedded as strings during
|
|
1353
|
-
* CJS bundling, which doesn't work for binary data).
|
|
1354
|
-
*/
|
|
1355
|
-
textFile(...segments: string[]): string;
|
|
1356
|
-
/**
|
|
1357
|
-
* Read a file and process it with Mustache template engine
|
|
1358
|
-
* @param params - Parameters to pass to the template
|
|
1359
|
-
* @param segments - Path segments to the template file
|
|
1360
|
-
*/
|
|
1361
|
-
mustache(params: Record<string, unknown>, ...segments: string[]): string;
|
|
1362
|
-
/**
|
|
1363
|
-
* Create a scoped TemplateFS with an implicit path prefix
|
|
1364
|
-
* @param prefix - Path segment to prepend to all operations
|
|
1365
|
-
* @returns New TemplateFS instance with the prefix applied
|
|
1366
|
-
*/
|
|
1367
|
-
scope(prefix: string): _TemplateFS;
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
/**
|
|
1371
|
-
* Generic template manager
|
|
1372
|
-
* Manages template selection and generation with full type safety
|
|
1373
|
-
*
|
|
1374
|
-
* @typeParam TParams - Template parameters type
|
|
1375
|
-
* @typeParam TOutput - Template output type (must extend TemplateOutput)
|
|
1376
|
-
* @typeParam TTemplate - Concrete template type (defaults to Template; specify to preserve extra fields in getTemplateEntries)
|
|
1377
|
-
* @internal
|
|
1378
|
-
*/
|
|
1379
|
-
export declare class _TemplateManager<TParams, TOutput extends _TemplateOutput = _TemplateOutput, TTemplate extends _Template<TParams, TOutput> = _Template<TParams, TOutput>> {
|
|
1380
|
-
private readonly templates;
|
|
1381
|
-
private readonly fs;
|
|
1382
|
-
/**
|
|
1383
|
-
* Create a new TemplateManager
|
|
1384
|
-
* @param templates - Object mapping string keys to templates
|
|
1385
|
-
* @param fs - Filesystem abstraction for template file reading
|
|
1386
|
-
*
|
|
1387
|
-
* @example
|
|
1388
|
-
* ```typescript
|
|
1389
|
-
* import { fs } from './fs/index.js';
|
|
1390
|
-
*
|
|
1391
|
-
* const manager = new TemplateManager({
|
|
1392
|
-
* foo: fooTemplate,
|
|
1393
|
-
* bar: barTemplate,
|
|
1394
|
-
* }, fs)
|
|
1395
|
-
*
|
|
1396
|
-
* await manager.generate('foo', params)
|
|
1397
|
-
* ```
|
|
1398
|
-
*/
|
|
1399
|
-
constructor(templates: Record<string, TTemplate>, fs: _TemplateFS);
|
|
1400
|
-
/**
|
|
1401
|
-
* Generate output from a template
|
|
1402
|
-
* @param key - Template key to generate from
|
|
1403
|
-
* @param params - Template-specific parameters
|
|
1404
|
-
* @returns Template output with files and any additional fields
|
|
1405
|
-
* @throws Error if template key is not found
|
|
1406
|
-
*/
|
|
1407
|
-
generate(key: string, params: TParams): Promise<TOutput>;
|
|
1408
|
-
/**
|
|
1409
|
-
* Get all template entries as [key, template] pairs
|
|
1410
|
-
*/
|
|
1411
|
-
protected getTemplateEntries(): [string, TTemplate][];
|
|
1412
|
-
/**
|
|
1413
|
-
* Get list of all supported template keys
|
|
1414
|
-
*/
|
|
1415
|
-
getSupportedKeys(): string[];
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
/**
|
|
1419
|
-
* ExtensionTemplateManager configured with built-in templates
|
|
1420
|
-
* Automatically selects filesystem or in-memory implementation
|
|
1421
|
-
* @internal
|
|
1422
|
-
*/
|
|
1423
|
-
export declare const _templateManager: _ExtensionTemplateManager;
|
|
1424
|
-
|
|
1425
|
-
/**
|
|
1426
|
-
* Base template output - always includes files array
|
|
1427
|
-
* Extend this interface to add additional output fields
|
|
1428
|
-
* @internal
|
|
1429
|
-
*/
|
|
1430
|
-
export declare interface _TemplateOutput {
|
|
1431
|
-
/** Files to write to disk. */
|
|
1432
|
-
files: _GeneratedFile[];
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
/**
|
|
1436
|
-
* A dependency required by a workspace: runtime npm, dev npm, or Stripe CLI plugin.
|
|
1437
|
-
* @internal
|
|
1438
|
-
*/
|
|
1439
|
-
export declare type _WorkspaceDependency = {
|
|
1440
|
-
minVersion?: string;
|
|
1441
|
-
name: string;
|
|
1442
|
-
type: 'stripe-cli-plugin';
|
|
1443
|
-
} | {
|
|
1444
|
-
name: string;
|
|
1445
|
-
type: 'dev-npm';
|
|
1446
|
-
version: string;
|
|
1447
|
-
} | {
|
|
1448
|
-
name: string;
|
|
1449
|
-
type: 'npm';
|
|
1450
|
-
version: string;
|
|
1451
|
-
};
|
|
1452
|
-
|
|
1453
|
-
/**
|
|
1454
|
-
* Interface for managing workspace dependency installation.
|
|
1455
|
-
* @internal
|
|
1456
|
-
*/
|
|
1457
|
-
export declare interface _WorkspaceDependencyManager {
|
|
1458
|
-
/** Analyze and queue the given dependencies for installation. */
|
|
1459
|
-
ensureDependencies(input: {
|
|
1460
|
-
optional?: _WorkspaceDependency[];
|
|
1461
|
-
required: _WorkspaceDependency[];
|
|
1462
|
-
}): Promise<_WorkspacePendingChange[]>;
|
|
1463
|
-
/** Mark a conflicting dependency as resolved so it will be force-installed. */
|
|
1464
|
-
resolveConflict(dep: _WorkspaceDependency): void;
|
|
1465
|
-
/** Apply all queued dependency changes. */
|
|
1466
|
-
commit(): Promise<unknown>;
|
|
1467
|
-
}
|
|
1468
|
-
|
|
1469
|
-
/**
|
|
1470
|
-
* Extension configuration used by the workspace manifest interface.
|
|
1471
|
-
* @internal
|
|
1472
|
-
*/
|
|
1473
|
-
export declare interface _WorkspaceExtensionConfig {
|
|
1474
|
-
/** Extension identifier. */
|
|
1475
|
-
id: string;
|
|
1476
|
-
/** Human-readable extension name. */
|
|
1477
|
-
name: string;
|
|
1478
|
-
/** Extension interface ID. */
|
|
1479
|
-
interface_id: string;
|
|
1480
|
-
/** Extension version string. */
|
|
1481
|
-
version: string;
|
|
1482
|
-
/** Legacy entry point script path. */
|
|
1483
|
-
script_entry_point?: string;
|
|
1484
|
-
/** Inline script definition. */
|
|
1485
|
-
script?: {
|
|
1486
|
-
content: string;
|
|
1487
|
-
type: string;
|
|
1488
|
-
};
|
|
1489
|
-
/** Required permissions for the extension. */
|
|
1490
|
-
permissions: string[];
|
|
1491
|
-
/** Method implementations keyed by method name. */
|
|
1492
|
-
methods: Record<string, unknown>;
|
|
1493
|
-
/** Optional configuration schemas. */
|
|
1494
|
-
configuration?: {
|
|
1495
|
-
input_schema: {
|
|
1496
|
-
content: string;
|
|
1497
|
-
type: 'json_schema' | 'jsonforms';
|
|
1498
|
-
};
|
|
1499
|
-
ui_schema: {
|
|
1500
|
-
content: string;
|
|
1501
|
-
type: 'json_schema' | 'jsonforms';
|
|
1502
|
-
};
|
|
1503
|
-
};
|
|
1504
|
-
/** Remote function endpoints. */
|
|
1505
|
-
endpoints?: {
|
|
1506
|
-
id: string;
|
|
1507
|
-
live?: _EndpointDefinition;
|
|
1508
|
-
managed_sandbox?: _EndpointDefinition;
|
|
1509
|
-
test?: _EndpointDefinition;
|
|
1510
|
-
type: 'custom_http' | 'remote_function';
|
|
1511
|
-
}[];
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
/**
|
|
1515
|
-
* Result of writing workspace files to disk.
|
|
1516
|
-
* @internal
|
|
1517
|
-
*/
|
|
1518
|
-
export declare interface _WorkspaceFileWriteResult {
|
|
1519
|
-
/** Paths of files that were written or overwritten. */
|
|
1520
|
-
written: string[];
|
|
1521
|
-
/** Paths of files that already existed and were not overwritten. */
|
|
1522
|
-
existing: string[];
|
|
1523
|
-
/** Whether all remaining files were skipped. */
|
|
1524
|
-
skipped: boolean;
|
|
1525
|
-
/** Whether the write operation was aborted by the user. */
|
|
1526
|
-
aborted: boolean;
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
/**
|
|
1530
|
-
* Options for writing workspace generated files to disk.
|
|
1531
|
-
* @internal
|
|
1532
|
-
*/
|
|
1533
|
-
export declare interface _WorkspaceFileWriterOptions {
|
|
1534
|
-
/** Working directory to resolve file paths against. */
|
|
1535
|
-
cwd?: string;
|
|
1536
|
-
/** Controls how existing files are handled. */
|
|
1537
|
-
write?: _WorkspaceWriteMode;
|
|
1538
|
-
/** Called after a file is written or overwritten. */
|
|
1539
|
-
onFileWritten?: (file: _WorkspaceGeneratedFile, wasOverwrite: boolean) => void;
|
|
1540
|
-
/** Called when a file is skipped due to the write mode. */
|
|
1541
|
-
onFileSkipped?: (file: _WorkspaceGeneratedFile) => void;
|
|
1542
|
-
/** Called when a file is identical to the existing one on disk. */
|
|
1543
|
-
onFileIdentical?: (file: _WorkspaceGeneratedFile) => void;
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
/**
|
|
1547
|
-
* A file generated by a workspace template.
|
|
1548
|
-
* @internal
|
|
1549
|
-
*/
|
|
1550
|
-
export declare interface _WorkspaceGeneratedFile {
|
|
1551
|
-
/** Path to the file, relative to the project root. */
|
|
1552
|
-
path: string;
|
|
1553
|
-
/** File content as a string. */
|
|
1554
|
-
content: string;
|
|
1555
|
-
/** If true, the file will never be overwritten even with `--force`. */
|
|
1556
|
-
precious?: boolean;
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
|
-
/**
|
|
1560
|
-
* Result returned by a workspace template generator.
|
|
1561
|
-
* @internal
|
|
1562
|
-
*/
|
|
1563
|
-
export declare interface _WorkspaceGenerateResult {
|
|
1564
|
-
/** Files to write to disk. */
|
|
1565
|
-
files: _WorkspaceGeneratedFile[];
|
|
1566
|
-
/** Dependencies to install after file generation. */
|
|
1567
|
-
dependencies?: {
|
|
1568
|
-
dev?: _WorkspaceDependency[];
|
|
1569
|
-
runtime?: _WorkspaceDependency[];
|
|
1570
|
-
};
|
|
1571
|
-
/** Hooks to run after dependencies are installed. */
|
|
1572
|
-
postGenerationHooks?: _WorkspacePostGenerationHook[];
|
|
1573
|
-
/** Methods configuration for the stripe-app.yaml extension entry. */
|
|
1574
|
-
methods?: Record<string, unknown>;
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
/**
|
|
1578
|
-
* Interface for reading and writing the stripe-app.yaml manifest.
|
|
1579
|
-
* @internal
|
|
1580
|
-
*/
|
|
1581
|
-
export declare interface _WorkspaceManifest {
|
|
1582
|
-
/** Add a new extension or replace an existing one by ID; returns the extension ID. */
|
|
1583
|
-
addOrUpdateExtension(config: _WorkspaceExtensionConfig): string;
|
|
1584
|
-
/** Get a read-only view of all registered extensions. */
|
|
1585
|
-
getExtensions(): readonly Readonly<_WorkspaceExtensionConfig>[];
|
|
1586
|
-
/** Check whether a custom object entry is already registered in the manifest. */
|
|
1587
|
-
hasCustomObject(entry: {
|
|
1588
|
-
className: string;
|
|
1589
|
-
filePath: string;
|
|
1590
|
-
}): boolean;
|
|
1591
|
-
/** Add a custom object entry to the manifest; returns true if added, false if already present. */
|
|
1592
|
-
addCustomObject(entry: {
|
|
1593
|
-
className: string;
|
|
1594
|
-
filePath: string;
|
|
1595
|
-
}): boolean;
|
|
1596
|
-
/** Persist the manifest to disk. */
|
|
1597
|
-
save(): Promise<void>;
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
/**
|
|
1601
|
-
* Decision returned by an overwrite prompt callback when a file already exists.
|
|
1602
|
-
* @internal
|
|
1603
|
-
*/
|
|
1604
|
-
export declare type _WorkspaceOverwriteDecision = 'abort' | 'overwrite-all' | 'overwrite' | 'skip';
|
|
1605
|
-
|
|
1606
|
-
/**
|
|
1607
|
-
* Callback invoked when a file to be written already exists, prompting for an overwrite decision.
|
|
1608
|
-
* @internal
|
|
1609
|
-
*/
|
|
1610
|
-
export declare type _WorkspaceOverwritePromptCallback = (path: string, cwd: string, newContent: string) => Promise<_WorkspaceOverwriteDecision>;
|
|
1611
|
-
|
|
1612
|
-
/**
|
|
1613
|
-
* A pending dependency change in the workspace dependency manager.
|
|
1614
|
-
* @internal
|
|
1615
|
-
*/
|
|
1616
|
-
export declare interface _WorkspacePendingChange {
|
|
1617
|
-
/** The dependency this change applies to. */
|
|
1618
|
-
dependency: _WorkspaceDependency;
|
|
1619
|
-
/** The action that will be taken. */
|
|
1620
|
-
action: 'add' | 'already-satisfied' | 'conflict' | 'update';
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
/**
|
|
1624
|
-
* A post-generation hook to run after files are written: either a pnpm script or a direct exec.
|
|
1625
|
-
* @internal
|
|
1626
|
-
*/
|
|
1627
|
-
export declare type _WorkspacePostGenerationHook = {
|
|
1628
|
-
description?: string;
|
|
1629
|
-
exec: string;
|
|
1630
|
-
} | {
|
|
1631
|
-
description?: string;
|
|
1632
|
-
script: string;
|
|
1633
|
-
};
|
|
1634
|
-
|
|
1635
|
-
/**
|
|
1636
|
-
* Injectable collaborators for _regenAppProjectWorkspace.
|
|
1637
|
-
* Defaults to real implementations; override individual fields for testing.
|
|
1638
|
-
* @internal
|
|
1639
|
-
*/
|
|
1640
|
-
export declare interface _WorkspaceServices {
|
|
1641
|
-
/** Generate root workspace files from template variables. */
|
|
1642
|
-
generateRoot: (vars: {
|
|
1643
|
-
appId: string;
|
|
1644
|
-
appName: string;
|
|
1645
|
-
version: string;
|
|
1646
|
-
}) => Promise<_WorkspaceGenerateResult>;
|
|
1647
|
-
/** Generate extension workspace files for the given template key and variables. */
|
|
1648
|
-
generateExtension: (key: string, vars: {
|
|
1649
|
-
id: string;
|
|
1650
|
-
name: string;
|
|
1651
|
-
version: string;
|
|
1652
|
-
}) => Promise<_WorkspaceGenerateResult>;
|
|
1653
|
-
/** Write generated files to disk with the given options. */
|
|
1654
|
-
writeFiles: (files: _WorkspaceGeneratedFile[], options?: _WorkspaceFileWriterOptions) => Promise<_WorkspaceFileWriteResult>;
|
|
1655
|
-
/** Create a dependency manager scoped to the given working directory. */
|
|
1656
|
-
createDepManager: (opts: {
|
|
1657
|
-
context?: _CliContext;
|
|
1658
|
-
cwd: string;
|
|
1659
|
-
}) => _WorkspaceDependencyManager;
|
|
1660
|
-
/** Generate custom object files (definition and test) from a name. */
|
|
1661
|
-
generateCustomObject: (vars: { name: string }) => Promise<_WorkspaceGenerateResult>;
|
|
1662
|
-
/** Generate the custom-objects workspace scaffolding (package.json, tsconfig.json). */
|
|
1663
|
-
generateCustomObjectsWorkspace: (vars: { packagesSubfolder?: string }) => Promise<_WorkspaceGenerateResult>;
|
|
1664
|
-
/** Load the stripe-app.yaml manifest from the given path. */
|
|
1665
|
-
loadManifest: (manifestPath: string) => Promise<_WorkspaceManifest>;
|
|
1666
|
-
/** Run post-generation hooks in the given working directory. */
|
|
1667
|
-
runHooks: (hooks: _WorkspacePostGenerationHook[] | undefined, workingDir: string, disabled?: boolean, context?: _CliContext) => Promise<void>;
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
|
-
/**
|
|
1671
|
-
* Controls how the file writer handles existing files.
|
|
1672
|
-
* @internal
|
|
1673
|
-
*/
|
|
1674
|
-
export declare type _WorkspaceWriteMode = _WorkspaceOverwritePromptCallback | 'abort-if-existing' | 'if-missing' | 'overwrite-all';
|
|
1675
|
-
|
|
1676
|
-
/**
|
|
1677
|
-
* Write generated files to disk with configurable write behavior
|
|
1678
|
-
*
|
|
1679
|
-
* Write modes:
|
|
1680
|
-
* - 'overwrite-all': Overwrite all existing files without prompting
|
|
1681
|
-
* - 'abort-if-existing': Refuse to write ANY files if ANY exist (all-or-nothing, sets skipped=true)
|
|
1682
|
-
* - 'if-missing': Write only files that don't exist, skip existing ones individually
|
|
1683
|
-
* - function: Prompt for each existing file (y/n/a/q), allows selective overwriting
|
|
1684
|
-
*
|
|
1685
|
-
* Always creates parent directories as needed (mkdir -p behavior)
|
|
1686
|
-
*
|
|
1687
|
-
* @param files - Files to write
|
|
1688
|
-
* @param options - Write options (cwd, write mode, callbacks)
|
|
1689
|
-
* @returns Result with written files, existing files, and skip status
|
|
1690
|
-
*
|
|
1691
|
-
* @example
|
|
1692
|
-
* ```typescript
|
|
1693
|
-
* // All-or-nothing mode
|
|
1694
|
-
* const result = await _writeGeneratedFiles(files, {
|
|
1695
|
-
* cwd: process.cwd(),
|
|
1696
|
-
* write: 'abort-if-existing'
|
|
1697
|
-
* })
|
|
1698
|
-
* if (result.skipped) {
|
|
1699
|
-
* throw new Error(`Files exist: ${result.existing.join(', ')}`)
|
|
1700
|
-
* }
|
|
1701
|
-
*
|
|
1702
|
-
* // Interactive mode
|
|
1703
|
-
* await _writeGeneratedFiles(files, {
|
|
1704
|
-
* cwd: process.cwd(),
|
|
1705
|
-
* write: async (path, newContent) => await _promptOverwrite(path)
|
|
1706
|
-
* })
|
|
1707
|
-
* ```
|
|
1708
|
-
* @internal
|
|
1709
|
-
*/
|
|
1710
|
-
export declare function _writeGeneratedFiles(files: _GeneratedFile[], options?: _FileWriterOptions): Promise<_FileWriteResult>;
|
|
1711
|
-
|
|
1712
|
-
/**
|
|
1713
|
-
* File write behavior modes
|
|
1714
|
-
* - 'overwrite-all': Overwrite all existing files
|
|
1715
|
-
* - 'abort-if-existing': Refuse to write ANY files if ANY already exist (all-or-nothing)
|
|
1716
|
-
* - 'if-missing': Skip individual files that exist, write only missing files
|
|
1717
|
-
* - function: Prompt before overwriting each file (interactive ask mode)
|
|
1718
|
-
* @internal
|
|
1719
|
-
*/
|
|
1720
|
-
export declare type _WriteMode = _OverwritePromptCallback | 'abort-if-existing' | 'if-missing' | 'overwrite-all';
|
|
1721
|
-
|
|
1722
|
-
export { }
|