@stripe/extensibility-custom-objects-tools 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +19 -0
- package/README.md +32 -0
- package/dist/build/build.d.ts +46 -0
- package/dist/build/build.d.ts.map +1 -0
- package/dist/build/cli.cjs +992 -0
- package/dist/build/cli.d.ts +3 -0
- package/dist/build/cli.d.ts.map +1 -0
- package/dist/build/cli.js +991 -0
- package/dist/build/extract-schemas.cli.cjs +8747 -0
- package/dist/build/extract-schemas.cli.d.ts +9 -0
- package/dist/build/extract-schemas.cli.d.ts.map +1 -0
- package/dist/build/extract-schemas.cli.js +8738 -0
- package/dist/build/extract-schemas.d.ts +17 -0
- package/dist/build/extract-schemas.d.ts.map +1 -0
- package/dist/build/package-build.d.ts +115 -0
- package/dist/build/package-build.d.ts.map +1 -0
- package/dist/extensibility-custom-objects-tools-alpha.d.ts +153 -0
- package/dist/extensibility-custom-objects-tools-beta.d.ts +32 -0
- package/dist/extensibility-custom-objects-tools-internal-alpha.d.ts +77 -0
- package/dist/extensibility-custom-objects-tools-internal-beta.d.ts +77 -0
- package/dist/extensibility-custom-objects-tools-internal-internal.d.ts +475 -0
- package/dist/extensibility-custom-objects-tools-internal-public.d.ts +77 -0
- package/dist/extensibility-custom-objects-tools-internal.d.ts +153 -0
- package/dist/extensibility-custom-objects-tools-public.d.ts +32 -0
- package/dist/generators/index.d.ts +43 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/index.cjs +956 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +927 -0
- package/dist/internal.cjs +8820 -0
- package/dist/internal.d.ts +7 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +8791 -0
- package/dist/transformer/classify-fields.d.ts +105 -0
- package/dist/transformer/classify-fields.d.ts.map +1 -0
- package/dist/transformer/generate-descriptors.d.ts +72 -0
- package/dist/transformer/generate-descriptors.d.ts.map +1 -0
- package/dist/transformer/metadata.d.ts +25 -0
- package/dist/transformer/metadata.d.ts.map +1 -0
- package/dist/transformer/transform.d.ts +35 -0
- package/dist/transformer/transform.d.ts.map +1 -0
- package/dist/transformer/types.d.ts +146 -0
- package/dist/transformer/types.d.ts.map +1 -0
- package/dist/transformer/visitors.d.ts +99 -0
- package/dist/transformer/visitors.d.ts.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/generators/custom-object/files/___packagesSubfolder___/src/___apiName___.object.ts.mustache +95 -0
- package/generators/custom-object-test/files/___packagesSubfolder___/src/___apiName___.object.test.ts.mustache +35 -0
- package/generators/custom-objects-workspace/files/___packagesSubfolder___/package.json.mustache +20 -0
- package/generators/custom-objects-workspace/files/___packagesSubfolder___/tsconfig.json +9 -0
- package/package.json +77 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import { JsonSchema2020 } from '@formspec/build';
|
|
2
|
+
import * as ts from 'typescript';
|
|
3
|
+
import { UISchema } from '@formspec/build';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema artifacts extracted for one action method.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare interface ActionSchemaResult {
|
|
11
|
+
name: string;
|
|
12
|
+
methodName: string;
|
|
13
|
+
apiName: string;
|
|
14
|
+
input: CustomObjectSchemaArtifacts | null;
|
|
15
|
+
output: {
|
|
16
|
+
jsonSchema: JsonSchema2020;
|
|
17
|
+
};
|
|
18
|
+
paramsSchema: JsonSchema2020 | Record<string, never>;
|
|
19
|
+
returnSchema: JsonSchema2020;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Structured result returned by an `afterExecute` hook.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
declare interface _AfterExecuteResult {
|
|
27
|
+
/** Descriptions of side effects that were performed. */
|
|
28
|
+
readonly sideEffects?: readonly string[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Structured result returned by a `beforeExecute` hook.
|
|
33
|
+
*
|
|
34
|
+
* Returning `{ proceed: false, reason: '...', remediation: '...' }` is a
|
|
35
|
+
* normal rejection — the user should fix their input. Throwing indicates a
|
|
36
|
+
* generator defect and should be filed as a bug.
|
|
37
|
+
*
|
|
38
|
+
* The discriminated union enforces that `reason` is always present when
|
|
39
|
+
* `proceed` is `false` — `{ proceed: false }` without a reason is a type error.
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
declare type _BeforeExecuteResult = {
|
|
43
|
+
readonly proceed: false;
|
|
44
|
+
readonly reason: string;
|
|
45
|
+
readonly remediation?: string;
|
|
46
|
+
} | { readonly proceed: true };
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Build schemas, UI specs, platform metadata, and transformed modules for a set of
|
|
50
|
+
* custom object exports using one shared TypeScript program.
|
|
51
|
+
*
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildCustomObjectPackage(options: BuildCustomObjectPackageOptions, dependencies?: {
|
|
55
|
+
createProgram?: (rootNames: readonly string[], options: ts.CompilerOptions) => ts.Program;
|
|
56
|
+
}): CustomObjectPackageBuildResult;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Options for building a package-scoped custom object artifact set.
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export declare interface BuildCustomObjectPackageOptions {
|
|
64
|
+
targets: BuildCustomObjectTarget[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* One custom object export to include in a package-scoped build.
|
|
69
|
+
*
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
export declare interface BuildCustomObjectTarget {
|
|
73
|
+
modulePath: string;
|
|
74
|
+
exportName: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Diagnostic emitted while building custom object package artifacts.
|
|
79
|
+
*
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
export declare interface BuildDiagnostic {
|
|
83
|
+
severity: 'error' | 'warning';
|
|
84
|
+
code: string;
|
|
85
|
+
message: string;
|
|
86
|
+
modulePath?: string;
|
|
87
|
+
exportName?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Backwards-compatible alias for the combined build artifact.
|
|
92
|
+
*
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
export declare type CustomObjectBuildArtifact = CustomObjectBuildResult;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Combined schema and metadata artifacts for one custom object export.
|
|
99
|
+
*
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
102
|
+
export declare interface CustomObjectBuildResult {
|
|
103
|
+
platformMetadata: CustomObjectPlatformMetadata;
|
|
104
|
+
fields: CustomObjectSchemaArtifacts;
|
|
105
|
+
fieldsSchema: JsonSchema2020;
|
|
106
|
+
fieldsUiSchema: UISchema | null;
|
|
107
|
+
actions: Record<string, ActionSchemaResult>;
|
|
108
|
+
primaryDisplayProperty?: string;
|
|
109
|
+
secondaryDisplayProperty?: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Generator that produces a `.object.ts` custom object definition file.
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
export declare const _customObjectGenerator: _Generator<_CustomObjectParams>;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Composite generator that produces both the object definition and its test file.
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
export declare const _customObjectGenerators: _GeneratorRunner<_CustomObjectParams>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Package-scoped custom object build output.
|
|
126
|
+
*
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
129
|
+
export declare interface CustomObjectPackageBuildResult {
|
|
130
|
+
objects: Record<string, CustomObjectBuildResult>;
|
|
131
|
+
transformedModules: Record<string, string>;
|
|
132
|
+
diagnostics: BuildDiagnostic[];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* User-provided parameters for the custom object generators.
|
|
137
|
+
* @internal
|
|
138
|
+
*/
|
|
139
|
+
export declare interface _CustomObjectParams {
|
|
140
|
+
/** User-provided object name (e.g., "Device", "VehicleRental") */
|
|
141
|
+
name: string;
|
|
142
|
+
/** Subfolder containing custom object packages (default: 'custom-objects') */
|
|
143
|
+
packagesSubfolder?: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Platform naming metadata for one built custom object.
|
|
148
|
+
*
|
|
149
|
+
* @internal
|
|
150
|
+
*/
|
|
151
|
+
export declare interface CustomObjectPlatformMetadata {
|
|
152
|
+
modulePath: string;
|
|
153
|
+
className: string;
|
|
154
|
+
apiName: string;
|
|
155
|
+
displayName: string;
|
|
156
|
+
displayNamePlural: string;
|
|
157
|
+
apiNamePlural: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The JSON Schema and JSON Forms artifacts for one extracted surface.
|
|
162
|
+
*
|
|
163
|
+
* @internal
|
|
164
|
+
*/
|
|
165
|
+
export declare interface CustomObjectSchemaArtifacts {
|
|
166
|
+
jsonSchema: JsonSchema2020;
|
|
167
|
+
uiSchema: UISchema | null;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Generator that produces the custom-objects workspace scaffolding
|
|
172
|
+
* (package.json, tsconfig.json). Run before any individual custom object
|
|
173
|
+
* generators when the workspace doesn't exist yet.
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
export declare const _customObjectsWorkspaceGenerator: _Generator<_CustomObjectsWorkspaceParams>;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* User-provided parameters for the custom-objects workspace scaffolding generator.
|
|
180
|
+
* Does not require a specific object name — only the subfolder placement matters.
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
183
|
+
export declare interface _CustomObjectsWorkspaceParams {
|
|
184
|
+
/** Subfolder containing custom object packages (default: 'custom-objects') */
|
|
185
|
+
packagesSubfolder?: string;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Generator that produces a `.object.test.ts` test file for a custom object.
|
|
190
|
+
* @internal
|
|
191
|
+
*/
|
|
192
|
+
export declare const _customObjectTestGenerator: _Generator<_CustomObjectParams>;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Extracts schemas from one custom object export.
|
|
196
|
+
*
|
|
197
|
+
* This is a convenience wrapper over the package-scoped builder.
|
|
198
|
+
*
|
|
199
|
+
* @internal
|
|
200
|
+
*/
|
|
201
|
+
export declare function extractCustomObjectSchemas(options: ExtractSchemasOptions): CustomObjectBuildResult;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Options for extracting schemas from a custom object class export.
|
|
205
|
+
*
|
|
206
|
+
* @internal
|
|
207
|
+
*/
|
|
208
|
+
export declare type ExtractSchemasOptions = BuildCustomObjectTarget;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Outcome of writing a single planned file to disk.
|
|
212
|
+
* @internal
|
|
213
|
+
*/
|
|
214
|
+
declare interface _FileWriteOutcome {
|
|
215
|
+
readonly path: string;
|
|
216
|
+
readonly decision: 'created' | 'identical' | 'overwritten' | 'skipped';
|
|
217
|
+
readonly proposedContent: string;
|
|
218
|
+
readonly previousContent?: string;
|
|
219
|
+
/**
|
|
220
|
+
* Present only when `decision` is `'skipped'` due to an error (not user choice).
|
|
221
|
+
* For permission errors, disk errors, etc. Not present on 'created', 'overwritten', or 'identical'.
|
|
222
|
+
*/
|
|
223
|
+
readonly error?: _WriteError;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* A composable unit of code generation.
|
|
228
|
+
*
|
|
229
|
+
* A generator combines:
|
|
230
|
+
* - A `files/` directory tree of Mustache templates that mirrors the output structure
|
|
231
|
+
* - A `locals()` function that computes template variables from user params
|
|
232
|
+
* - Optional lifecycle hooks for side effects (manifest updates, config changes)
|
|
233
|
+
*
|
|
234
|
+
* @typeParam TParams - User-provided parameters for this generator
|
|
235
|
+
* @internal
|
|
236
|
+
*/
|
|
237
|
+
declare interface _Generator<TParams extends object> {
|
|
238
|
+
/**
|
|
239
|
+
* Compute template variables from user-provided params.
|
|
240
|
+
*
|
|
241
|
+
* The returned record serves as the variable scope for both:
|
|
242
|
+
* - `___token___` resolution in file/directory names (structural placement)
|
|
243
|
+
* - `{{token}}` Mustache rendering in .mustache file content
|
|
244
|
+
*
|
|
245
|
+
* Params are the raw user inputs. Locals are the transformed, computed
|
|
246
|
+
* fields derived from params (e.g., PascalCase, snake_case, pluralized
|
|
247
|
+
* forms, default values). All template surfaces consume from locals.
|
|
248
|
+
*
|
|
249
|
+
* Path tokens (`___token___`) must resolve to strings.
|
|
250
|
+
* Content tokens (`{{token}}`) may be any Mustache-compatible value.
|
|
251
|
+
*/
|
|
252
|
+
locals(params: TParams): Record<string, unknown>;
|
|
253
|
+
/**
|
|
254
|
+
* Root directory of this generator (parent of the `files/` subdirectory).
|
|
255
|
+
* The runner will look for templates under `<filesDir>/files/`.
|
|
256
|
+
*/
|
|
257
|
+
readonly filesDir: string;
|
|
258
|
+
/**
|
|
259
|
+
* Map of template-relative file paths to human-readable descriptions.
|
|
260
|
+
*
|
|
261
|
+
* Keys are the literal filename in the `files/` tree (with `___token___`
|
|
262
|
+
* intact, e.g., `'___objectName___.object.ts.mustache'`). Values may use
|
|
263
|
+
* Mustache `{{token}}` syntax and are rendered with the generator's locals.
|
|
264
|
+
*
|
|
265
|
+
* Example:
|
|
266
|
+
* ```typescript
|
|
267
|
+
* descriptions: {
|
|
268
|
+
* '___objectName___.object.ts.mustache': 'Defines the {{className}} custom object',
|
|
269
|
+
* }
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
readonly descriptions?: Readonly<Record<string, string>>;
|
|
273
|
+
/**
|
|
274
|
+
* Run before files are generated (e.g., validate preconditions).
|
|
275
|
+
*
|
|
276
|
+
* Return `{ proceed: false, reason: '...', remediation: '...' }` to reject
|
|
277
|
+
* execution with user-actionable guidance.
|
|
278
|
+
*
|
|
279
|
+
* **Throwing** indicates a generator defect, not a user input problem.
|
|
280
|
+
*/
|
|
281
|
+
beforeExecute?(params: TParams, context: _GeneratorContext): Promise<_BeforeExecuteResult>;
|
|
282
|
+
/**
|
|
283
|
+
* Run after files are written (e.g., update manifest, install deps).
|
|
284
|
+
*
|
|
285
|
+
* Returns a structured description of side effects performed.
|
|
286
|
+
*
|
|
287
|
+
* Note: if `afterExecute` throws, files have already been written to disk.
|
|
288
|
+
* The error propagates to the caller. Callers should handle this as a
|
|
289
|
+
* partial-completion scenario.
|
|
290
|
+
*/
|
|
291
|
+
afterExecute?(params: TParams, context: _GeneratorContext, writeResult: _GeneratorWriteResult): Promise<_AfterExecuteResult>;
|
|
292
|
+
/**
|
|
293
|
+
* Return descriptions of side effects that `afterExecute` would perform,
|
|
294
|
+
* parameterized by the current params. Used for dry-run output.
|
|
295
|
+
*
|
|
296
|
+
* Returns a promise so future generators can inspect the filesystem to
|
|
297
|
+
* produce accurate descriptions.
|
|
298
|
+
*/
|
|
299
|
+
describeSideEffects?(params: TParams): Promise<readonly string[]>;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Discriminated union of the two generator context shapes.
|
|
304
|
+
* @internal
|
|
305
|
+
*/
|
|
306
|
+
declare type _GeneratorContext = _ProjectGeneratorContext | _StandaloneGeneratorContext;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Discriminated union of the two execute context shapes.
|
|
310
|
+
* @internal
|
|
311
|
+
*/
|
|
312
|
+
declare type _GeneratorExecuteContext = _ProjectExecuteContext | _StandaloneExecuteContext;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Result returned by `_GeneratorRunner.execute()`.
|
|
316
|
+
* @internal
|
|
317
|
+
*/
|
|
318
|
+
declare interface _GeneratorExecuteResult {
|
|
319
|
+
/** Files that were planned (same as plan().files). */
|
|
320
|
+
readonly files: readonly _PlannedFile[];
|
|
321
|
+
/** Preflight results from all `beforeExecute` hooks. */
|
|
322
|
+
readonly preflightResults: readonly _BeforeExecuteResult[];
|
|
323
|
+
/** Descriptions of side effects declared by generators. */
|
|
324
|
+
readonly plannedSideEffects: readonly string[];
|
|
325
|
+
/** The write result from the caller's `writeFiles` callback. Absent (undefined)
|
|
326
|
+
* if a preflight check rejected execution. */
|
|
327
|
+
readonly writeResult: _GeneratorWriteResult | undefined;
|
|
328
|
+
/** Results from all `afterExecute` hooks. */
|
|
329
|
+
readonly afterExecuteResults: readonly _AfterExecuteResult[];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Result of `_GeneratorRunner.plan()`.
|
|
334
|
+
* @internal
|
|
335
|
+
*/
|
|
336
|
+
declare interface _GeneratorPlanResult {
|
|
337
|
+
/** Files that would be generated. */
|
|
338
|
+
readonly files: readonly _PlannedFile[];
|
|
339
|
+
/** Preflight results from all `beforeExecute` hooks. */
|
|
340
|
+
readonly preflightResults: readonly _BeforeExecuteResult[];
|
|
341
|
+
/** Descriptions of side effects that `afterExecute` hooks would perform. */
|
|
342
|
+
readonly plannedSideEffects: readonly string[];
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Executes a single `_Generator` (or composite of generators), producing file
|
|
347
|
+
* outputs and running lifecycle hooks.
|
|
348
|
+
*
|
|
349
|
+
* Does NOT write files to disk — that responsibility belongs to the caller.
|
|
350
|
+
*
|
|
351
|
+
* @typeParam TParams - User-provided parameters type
|
|
352
|
+
* @internal
|
|
353
|
+
*/
|
|
354
|
+
declare class _GeneratorRunner<TParams extends object> {
|
|
355
|
+
#private;
|
|
356
|
+
constructor(generator: _Generator<TParams> | ReadonlyArray<_Generator<TParams>>);
|
|
357
|
+
/**
|
|
358
|
+
* Plan phase — compute all files that would be generated, without writing
|
|
359
|
+
* anything to disk.
|
|
360
|
+
*
|
|
361
|
+
* Also runs `beforeExecute` hooks to collect preflight results, and
|
|
362
|
+
* `describeSideEffects` to surface planned side effects. Neither of these
|
|
363
|
+
* write anything or produce observable external effects during plan.
|
|
364
|
+
*
|
|
365
|
+
* Use this for dry runs, previews, and testing.
|
|
366
|
+
*
|
|
367
|
+
* Validates that all output paths are safe (no `..`, no leading `/`) and
|
|
368
|
+
* that no two generators produce the same output path.
|
|
369
|
+
*
|
|
370
|
+
* @param params - User-provided parameters for the generator
|
|
371
|
+
* @param context - Generator context (standalone or project). Passed to
|
|
372
|
+
* `beforeExecute` hooks. Callers must supply a real context — there is no
|
|
373
|
+
* synthetic plan-time sentinel. For dry-run calls outside of a project,
|
|
374
|
+
* use a standalone context with an appropriate `targetDir`.
|
|
375
|
+
*/
|
|
376
|
+
plan(params: TParams, context: _GeneratorContext): Promise<_GeneratorPlanResult>;
|
|
377
|
+
/**
|
|
378
|
+
* Execute phase — runs the full lifecycle:
|
|
379
|
+
* 1. `plan()` to collect preflight results and planned files
|
|
380
|
+
* 2. If any preflight returned `proceed: false`, return early without writing
|
|
381
|
+
* 3. `context.writeFiles()` to write files to disk (delegated to caller)
|
|
382
|
+
* 4. If the write was aborted, return early without calling `afterExecute`
|
|
383
|
+
* 5. `afterExecute` hooks for all generators with the write result
|
|
384
|
+
*/
|
|
385
|
+
execute(params: TParams, context: _GeneratorExecuteContext): Promise<_GeneratorExecuteResult>;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Result of writing all planned files to disk.
|
|
390
|
+
* @internal
|
|
391
|
+
*/
|
|
392
|
+
declare interface _GeneratorWriteResult {
|
|
393
|
+
readonly fileOutcomes: readonly _FileWriteOutcome[];
|
|
394
|
+
readonly aborted: boolean;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* A single file that a generator intends to create.
|
|
399
|
+
* @internal
|
|
400
|
+
*/
|
|
401
|
+
declare interface _PlannedFile {
|
|
402
|
+
readonly path: string;
|
|
403
|
+
readonly content: string;
|
|
404
|
+
/**
|
|
405
|
+
* Human-readable explanation of what this file is and why it is being
|
|
406
|
+
* created. Rendered from the generator's `descriptions` map using Mustache.
|
|
407
|
+
*/
|
|
408
|
+
readonly description?: string;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Execute context for project-scoped generators.
|
|
413
|
+
* @internal
|
|
414
|
+
*/
|
|
415
|
+
declare type _ProjectExecuteContext = _ProjectGeneratorContext & _WriteCapability;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Generator context for a project-scoped invocation.
|
|
419
|
+
* The generator places files relative to `projectRoot`.
|
|
420
|
+
* @internal
|
|
421
|
+
*/
|
|
422
|
+
declare interface _ProjectGeneratorContext {
|
|
423
|
+
readonly scope: 'project';
|
|
424
|
+
readonly projectRoot: string;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Execute context for standalone generators.
|
|
429
|
+
* @internal
|
|
430
|
+
*/
|
|
431
|
+
declare type _StandaloneExecuteContext = _StandaloneGeneratorContext & _WriteCapability;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Generator abstraction for composable code generation
|
|
435
|
+
*
|
|
436
|
+
* A generator combines a `files/` directory tree of Mustache templates,
|
|
437
|
+
* a `locals()` function that computes template variables, and optional
|
|
438
|
+
* lifecycle hooks for side effects (manifest updates, config changes).
|
|
439
|
+
*/
|
|
440
|
+
/**
|
|
441
|
+
* Generator context for a standalone (non-project) invocation.
|
|
442
|
+
* The generator places files relative to `targetDir`.
|
|
443
|
+
* @internal
|
|
444
|
+
*/
|
|
445
|
+
declare interface _StandaloneGeneratorContext {
|
|
446
|
+
readonly scope: 'standalone';
|
|
447
|
+
readonly targetDir: string;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Build the canonical lookup key for one package-build target.
|
|
452
|
+
*
|
|
453
|
+
* @internal
|
|
454
|
+
*/
|
|
455
|
+
export declare function toObjectKey(target: BuildCustomObjectTarget): string;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Capability mixin that adds `writeFiles` to an execute context.
|
|
459
|
+
* @internal
|
|
460
|
+
*/
|
|
461
|
+
declare interface _WriteCapability {
|
|
462
|
+
/** Write generated files to disk. Provided by the caller. */
|
|
463
|
+
writeFiles(files: readonly _PlannedFile[]): Promise<_GeneratorWriteResult>;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Error detail attached to a file write outcome.
|
|
468
|
+
* @internal
|
|
469
|
+
*/
|
|
470
|
+
declare interface _WriteError {
|
|
471
|
+
readonly kind: 'conflict' | 'disk' | 'permission' | 'unknown';
|
|
472
|
+
readonly message: string;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export { }
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { JsonSchema2020 } from '@formspec/build';
|
|
2
|
+
import * as ts from 'typescript';
|
|
3
|
+
import { UISchema } from '@formspec/build';
|
|
4
|
+
|
|
5
|
+
/* Excluded from this release type: ActionSchemaResult */
|
|
6
|
+
|
|
7
|
+
/* Excluded from this release type: _AfterExecuteResult */
|
|
8
|
+
|
|
9
|
+
/* Excluded from this release type: _BeforeExecuteResult */
|
|
10
|
+
|
|
11
|
+
/* Excluded from this release type: buildCustomObjectPackage */
|
|
12
|
+
|
|
13
|
+
/* Excluded from this release type: BuildCustomObjectPackageOptions */
|
|
14
|
+
|
|
15
|
+
/* Excluded from this release type: BuildCustomObjectTarget */
|
|
16
|
+
|
|
17
|
+
/* Excluded from this release type: BuildDiagnostic */
|
|
18
|
+
|
|
19
|
+
/* Excluded from this release type: CustomObjectBuildArtifact */
|
|
20
|
+
|
|
21
|
+
/* Excluded from this release type: CustomObjectBuildResult */
|
|
22
|
+
|
|
23
|
+
/* Excluded from this release type: _customObjectGenerator */
|
|
24
|
+
|
|
25
|
+
/* Excluded from this release type: _customObjectGenerators */
|
|
26
|
+
|
|
27
|
+
/* Excluded from this release type: CustomObjectPackageBuildResult */
|
|
28
|
+
|
|
29
|
+
/* Excluded from this release type: _CustomObjectParams */
|
|
30
|
+
|
|
31
|
+
/* Excluded from this release type: CustomObjectPlatformMetadata */
|
|
32
|
+
|
|
33
|
+
/* Excluded from this release type: CustomObjectSchemaArtifacts */
|
|
34
|
+
|
|
35
|
+
/* Excluded from this release type: _customObjectsWorkspaceGenerator */
|
|
36
|
+
|
|
37
|
+
/* Excluded from this release type: _CustomObjectsWorkspaceParams */
|
|
38
|
+
|
|
39
|
+
/* Excluded from this release type: _customObjectTestGenerator */
|
|
40
|
+
|
|
41
|
+
/* Excluded from this release type: extractCustomObjectSchemas */
|
|
42
|
+
|
|
43
|
+
/* Excluded from this release type: ExtractSchemasOptions */
|
|
44
|
+
|
|
45
|
+
/* Excluded from this release type: _FileWriteOutcome */
|
|
46
|
+
|
|
47
|
+
/* Excluded from this release type: _Generator */
|
|
48
|
+
|
|
49
|
+
/* Excluded from this release type: _GeneratorContext */
|
|
50
|
+
|
|
51
|
+
/* Excluded from this release type: _GeneratorExecuteContext */
|
|
52
|
+
|
|
53
|
+
/* Excluded from this release type: _GeneratorExecuteResult */
|
|
54
|
+
|
|
55
|
+
/* Excluded from this release type: _GeneratorPlanResult */
|
|
56
|
+
|
|
57
|
+
/* Excluded from this release type: _GeneratorRunner */
|
|
58
|
+
|
|
59
|
+
/* Excluded from this release type: _GeneratorWriteResult */
|
|
60
|
+
|
|
61
|
+
/* Excluded from this release type: _PlannedFile */
|
|
62
|
+
|
|
63
|
+
/* Excluded from this release type: _ProjectExecuteContext */
|
|
64
|
+
|
|
65
|
+
/* Excluded from this release type: _ProjectGeneratorContext */
|
|
66
|
+
|
|
67
|
+
/* Excluded from this release type: _StandaloneExecuteContext */
|
|
68
|
+
|
|
69
|
+
/* Excluded from this release type: _StandaloneGeneratorContext */
|
|
70
|
+
|
|
71
|
+
/* Excluded from this release type: toObjectKey */
|
|
72
|
+
|
|
73
|
+
/* Excluded from this release type: _WriteCapability */
|
|
74
|
+
|
|
75
|
+
/* Excluded from this release type: _WriteError */
|
|
76
|
+
|
|
77
|
+
export { }
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@stripe/extensibility-custom-objects-tools`
|
|
3
|
+
*
|
|
4
|
+
* Build-time tooling for custom object extensions: schema transformation,
|
|
5
|
+
* metadata extraction, and code generation helpers.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Metadata for a single action (method).
|
|
12
|
+
* @alpha
|
|
13
|
+
*/
|
|
14
|
+
export declare interface ActionMetadata {
|
|
15
|
+
/** The method name */
|
|
16
|
+
methodName: string;
|
|
17
|
+
/** String representation of argument types */
|
|
18
|
+
argType: string;
|
|
19
|
+
/** String representation of return type */
|
|
20
|
+
returnType: string;
|
|
21
|
+
/** API name for the action (defaults to snake_case of method name) */
|
|
22
|
+
apiName: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Actions metadata for a custom object.
|
|
27
|
+
* Only instance methods are supported — static methods cannot be actions.
|
|
28
|
+
* @alpha
|
|
29
|
+
*/
|
|
30
|
+
export declare interface ActionsMetadata {
|
|
31
|
+
/** Instance-level actions */
|
|
32
|
+
instance: Record<string, ActionMetadata>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Builds the custom objects by transforming TypeScript files.
|
|
37
|
+
*
|
|
38
|
+
* @param options - Build options
|
|
39
|
+
* @returns Build result
|
|
40
|
+
* @alpha
|
|
41
|
+
*/
|
|
42
|
+
export declare function build(options: BuildOptions): Promise<BuildResult>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Options for the build process.
|
|
46
|
+
* @alpha
|
|
47
|
+
*/
|
|
48
|
+
export declare interface BuildOptions {
|
|
49
|
+
/** Input directory containing TypeScript source files */
|
|
50
|
+
inputDir: string;
|
|
51
|
+
/** Output directory for transformed files */
|
|
52
|
+
outputDir: string;
|
|
53
|
+
/** Whether to generate source maps (not yet implemented) */
|
|
54
|
+
sourceMap?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Result of the entire build process.
|
|
59
|
+
* @alpha
|
|
60
|
+
*/
|
|
61
|
+
export declare interface BuildResult {
|
|
62
|
+
/** Results for each processed file */
|
|
63
|
+
files: FileResult[];
|
|
64
|
+
/** Any global errors */
|
|
65
|
+
errors: TransformError[];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Result of transforming a single file.
|
|
70
|
+
* @alpha
|
|
71
|
+
*/
|
|
72
|
+
export declare interface FileResult {
|
|
73
|
+
/** Input file path */
|
|
74
|
+
inputPath: string;
|
|
75
|
+
/** Output file path */
|
|
76
|
+
outputPath: string;
|
|
77
|
+
/** Whether the transformation succeeded */
|
|
78
|
+
success: boolean;
|
|
79
|
+
/** Any errors that occurred */
|
|
80
|
+
errors: TransformError[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Platform metadata for a custom object class.
|
|
85
|
+
* @alpha
|
|
86
|
+
*/
|
|
87
|
+
export declare interface PlatformMetadata {
|
|
88
|
+
/** Module path that defined this custom object */
|
|
89
|
+
modulePath?: string;
|
|
90
|
+
/** Original TypeScript class name */
|
|
91
|
+
className?: string;
|
|
92
|
+
/** Canonical class api name */
|
|
93
|
+
classApiName?: string;
|
|
94
|
+
/** The api name of the custom object */
|
|
95
|
+
apiName: string;
|
|
96
|
+
/** All actions for this custom object */
|
|
97
|
+
actions: ActionsMetadata;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Transforms TypeScript source code with custom object decorators.
|
|
102
|
+
* Injects runtime code and extracts platform metadata.
|
|
103
|
+
*
|
|
104
|
+
* @param sourceCode - The TypeScript source code to transform
|
|
105
|
+
* @param fileName - Optional file name for error reporting
|
|
106
|
+
* @returns Transform result with code, metadata, and errors
|
|
107
|
+
* @deprecated Use `buildCustomObjectPackage` + `transformWithPlan` instead. This
|
|
108
|
+
* function performs source-only discovery without build-time schema analysis, so it
|
|
109
|
+
* cannot generate wire conversion descriptors and falls back to the legacy passthrough
|
|
110
|
+
* wrapper (no Decimal/DateTime hydration).
|
|
111
|
+
* @alpha
|
|
112
|
+
*/
|
|
113
|
+
export declare function transform(sourceCode: string, fileName?: string): TransformResult;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* An error that occurred during transformation.
|
|
117
|
+
* @alpha
|
|
118
|
+
*/
|
|
119
|
+
export declare interface TransformError {
|
|
120
|
+
/** Error message */
|
|
121
|
+
message: string;
|
|
122
|
+
/** File path (if available) */
|
|
123
|
+
file?: string;
|
|
124
|
+
/** Line number (if available) */
|
|
125
|
+
line?: number;
|
|
126
|
+
/** Column number (if available) */
|
|
127
|
+
column?: number;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Transforms a TypeScript file from disk.
|
|
132
|
+
*
|
|
133
|
+
* @param filePath - Path to the TypeScript file
|
|
134
|
+
* @returns Transform result with code, metadata, and errors
|
|
135
|
+
* @deprecated Delegates to the deprecated `transform()`. Use `buildCustomObjectPackage` instead.
|
|
136
|
+
* @alpha
|
|
137
|
+
*/
|
|
138
|
+
export declare function transformFile(filePath: string): Promise<TransformResult>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Result of transforming source code.
|
|
142
|
+
* @alpha
|
|
143
|
+
*/
|
|
144
|
+
export declare interface TransformResult {
|
|
145
|
+
/** Transformed source code */
|
|
146
|
+
code: string;
|
|
147
|
+
/** Platform metadata extracted from all custom objects */
|
|
148
|
+
metadata: PlatformMetadata[];
|
|
149
|
+
/** Any errors encountered during transformation */
|
|
150
|
+
errors: TransformError[];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export { }
|