@stripe/extensibility-tool-utils 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +19 -0
- package/dist/cli/cli-ux.d.ts +30 -0
- package/dist/cli/cli-ux.d.ts.map +1 -0
- package/dist/cli/context.d.ts +24 -0
- package/dist/cli/context.d.ts.map +1 -0
- package/dist/cli/guards.d.ts +24 -0
- package/dist/cli/guards.d.ts.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/output-path.d.ts +11 -0
- package/dist/cli/output-path.d.ts.map +1 -0
- package/dist/extensibility-tool-utils-alpha.d.ts +383 -0
- package/dist/extensibility-tool-utils-beta.d.ts +383 -0
- package/dist/extensibility-tool-utils-internal.d.ts +1866 -0
- package/dist/extensibility-tool-utils-public.d.ts +383 -0
- package/dist/file-editor/assertions/index.d.ts +68 -0
- package/dist/file-editor/assertions/index.d.ts.map +1 -0
- package/dist/file-editor/document.d.ts +107 -0
- package/dist/file-editor/document.d.ts.map +1 -0
- package/dist/file-editor/errors.d.ts +66 -0
- package/dist/file-editor/errors.d.ts.map +1 -0
- package/dist/file-editor/facades/api-extractor.d.ts +34 -0
- package/dist/file-editor/facades/api-extractor.d.ts.map +1 -0
- package/dist/file-editor/facades/brands.d.ts +45 -0
- package/dist/file-editor/facades/brands.d.ts.map +1 -0
- package/dist/file-editor/facades/package-json.d.ts +55 -0
- package/dist/file-editor/facades/package-json.d.ts.map +1 -0
- package/dist/file-editor/facades/stripe-app-manifest.d.ts +62 -0
- package/dist/file-editor/facades/stripe-app-manifest.d.ts.map +1 -0
- package/dist/file-editor/facades/tsconfig-options.d.ts +76 -0
- package/dist/file-editor/facades/tsconfig-options.d.ts.map +1 -0
- package/dist/file-editor/facades/tsconfig.d.ts +43 -0
- package/dist/file-editor/facades/tsconfig.d.ts.map +1 -0
- package/dist/file-editor/fingerprint.d.ts +39 -0
- package/dist/file-editor/fingerprint.d.ts.map +1 -0
- package/dist/file-editor/formats/adapter.d.ts +29 -0
- package/dist/file-editor/formats/adapter.d.ts.map +1 -0
- package/dist/file-editor/formats/detect.d.ts +9 -0
- package/dist/file-editor/formats/detect.d.ts.map +1 -0
- package/dist/file-editor/formats/index.d.ts +13 -0
- package/dist/file-editor/formats/index.d.ts.map +1 -0
- package/dist/file-editor/formats/jsonc.d.ts +14 -0
- package/dist/file-editor/formats/jsonc.d.ts.map +1 -0
- package/dist/file-editor/formats/yaml.d.ts +11 -0
- package/dist/file-editor/formats/yaml.d.ts.map +1 -0
- package/dist/file-editor/index.d.ts +42 -0
- package/dist/file-editor/index.d.ts.map +1 -0
- package/dist/file-editor/pointer.d.ts +74 -0
- package/dist/file-editor/pointer.d.ts.map +1 -0
- package/dist/file-editor/schema.d.ts +72 -0
- package/dist/file-editor/schema.d.ts.map +1 -0
- package/dist/file-editor/state/fs-manifest.d.ts +30 -0
- package/dist/file-editor/state/fs-manifest.d.ts.map +1 -0
- package/dist/file-editor/state/in-memory.d.ts +5 -0
- package/dist/file-editor/state/in-memory.d.ts.map +1 -0
- package/dist/file-editor/state/store.d.ts +19 -0
- package/dist/file-editor/state/store.d.ts.map +1 -0
- package/dist/file-editor/transaction.d.ts +60 -0
- package/dist/file-editor/transaction.d.ts.map +1 -0
- package/dist/file-editor/types.d.ts +131 -0
- package/dist/file-editor/types.d.ts.map +1 -0
- package/dist/file-editor/util/atomic-write.d.ts +7 -0
- package/dist/file-editor/util/atomic-write.d.ts.map +1 -0
- package/dist/file-editor/util/diff.d.ts +20 -0
- package/dist/file-editor/util/diff.d.ts.map +1 -0
- package/dist/file-editor/value-at-pointer.d.ts +46 -0
- package/dist/file-editor/value-at-pointer.d.ts.map +1 -0
- package/dist/index.cjs +2967 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2847 -0
- package/dist/logging/create-logger.d.ts +29 -0
- package/dist/logging/create-logger.d.ts.map +1 -0
- package/dist/logging/index.d.ts +10 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/levels.d.ts +21 -0
- package/dist/logging/levels.d.ts.map +1 -0
- package/dist/naming/inflection.d.ts +15 -0
- package/dist/naming/inflection.d.ts.map +1 -0
- package/dist/naming/metadata-policy.d.ts +35 -0
- package/dist/naming/metadata-policy.d.ts.map +1 -0
- package/dist/naming/stripe-api-case.d.ts +9 -0
- package/dist/naming/stripe-api-case.d.ts.map +1 -0
- package/dist/naming/types.d.ts +11 -0
- package/dist/naming/types.d.ts.map +1 -0
- package/dist/naming/validate.d.ts +6 -0
- package/dist/naming/validate.d.ts.map +1 -0
- package/dist/templates/filesystem-fs.d.ts +20 -0
- package/dist/templates/filesystem-fs.d.ts.map +1 -0
- package/dist/templates/generator.d.ts +305 -0
- package/dist/templates/generator.d.ts.map +1 -0
- package/dist/templates/in-memory-fs.d.ts +44 -0
- package/dist/templates/in-memory-fs.d.ts.map +1 -0
- package/dist/templates/index.d.ts +28 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/simple-templates.d.ts +75 -0
- package/dist/templates/simple-templates.d.ts.map +1 -0
- package/dist/templates/template-manager.d.ts +54 -0
- package/dist/templates/template-manager.d.ts.map +1 -0
- package/dist/templates/types.d.ts +87 -0
- package/dist/templates/types.d.ts.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/workspace-versions.d.ts +30 -0
- package/dist/workspace-versions.d.ts.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger factory for extensibility tooling.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
import pino from 'pino';
|
|
7
|
+
import type { _LogLevel } from './levels.js';
|
|
8
|
+
/**
|
|
9
|
+
* Options for creating a logger instance.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export interface _LoggerOptions {
|
|
14
|
+
/** Optional name tag included in every log record. */
|
|
15
|
+
readonly name?: string;
|
|
16
|
+
/** Log level; defaults to the LOG_LEVEL env var, falling back to 'info'. */
|
|
17
|
+
readonly level?: _LogLevel;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a pino logger that writes to stderr with colorized pretty-print output.
|
|
21
|
+
* Stderr is used so that structured log lines do not pollute stdout-based CLI output.
|
|
22
|
+
*
|
|
23
|
+
* @param options - Optional name and level overrides.
|
|
24
|
+
* @returns A configured pino Logger instance.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare function _createLogger(options?: _LoggerOptions): pino.Logger;
|
|
29
|
+
//# sourceMappingURL=create-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-logger.d.ts","sourceRoot":"","sources":["../../src/logging/create-logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,sDAAsD;IACtD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC,MAAM,CAWnE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging utilities for extensibility tooling.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export type { _LogLevel } from './levels.js';
|
|
7
|
+
export { _parseLogLevel } from './levels.js';
|
|
8
|
+
export type { _LoggerOptions } from './create-logger.js';
|
|
9
|
+
export { _createLogger } from './create-logger.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logging/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log level type and parsing utilities.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Valid pino log levels, including 'silent' to suppress all output.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export type _LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'silent';
|
|
12
|
+
/**
|
|
13
|
+
* Parses a log level string, returning 'info' for missing or unrecognized values.
|
|
14
|
+
*
|
|
15
|
+
* @param input - Raw string (e.g. from an env var). Undefined or empty returns 'info'.
|
|
16
|
+
* @returns A valid _LogLevel.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare function _parseLogLevel(input: string | undefined): _LogLevel;
|
|
21
|
+
//# sourceMappingURL=levels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"levels.d.ts","sourceRoot":"","sources":["../../src/logging/levels.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,OAAO,GACP,MAAM,GACN,MAAM,GACN,OAAO,GACP,OAAO,GACP,QAAQ,CAAC;AAiBb;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAKnE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Converts a snake_case identifier to PascalCase. @internal */
|
|
2
|
+
export declare function _toPascalCase(value: string): string;
|
|
3
|
+
/** Converts a PascalCase or camelCase identifier to snake_case. @internal */
|
|
4
|
+
export declare function _toSnakeCase(value: string): string;
|
|
5
|
+
/** Pluralizes a name using the `inflected` library. @internal */
|
|
6
|
+
export declare function _toPlural(value: string): string;
|
|
7
|
+
/** Singularizes a name using the `inflected` library. @internal */
|
|
8
|
+
export declare function _toSingular(value: string): string;
|
|
9
|
+
/** Returns whether a name appears plural according to the inflector. @internal */
|
|
10
|
+
export declare function _looksPlural(value: string): boolean;
|
|
11
|
+
/** Capitalizes the first character of a string, leaving the rest unchanged. @internal */
|
|
12
|
+
export declare function _toCapitalized(value: string): string;
|
|
13
|
+
/** Returns whether a name appears singular according to the inflector. @internal */
|
|
14
|
+
export declare function _looksSingular(value: string): boolean;
|
|
15
|
+
//# sourceMappingURL=inflection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inflection.d.ts","sourceRoot":"","sources":["../../src/naming/inflection.ts"],"names":[],"mappings":"AAEA,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,mEAAmE;AACnE,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGnD;AAED,yFAAyF;AACzF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAErD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { MetadataInferenceContext, MetadataPluralizationContext, MetadataPolicyInput } from '@formspec/core';
|
|
2
|
+
/**
|
|
3
|
+
* Infers a Stripe API name from a declaration's logical TypeScript name.
|
|
4
|
+
*
|
|
5
|
+
* FormSpec passes the unresolved declaration identifier through
|
|
6
|
+
* `logicalName`. Stripe naming policy lowers that identifier into Stripe API
|
|
7
|
+
* case so schema generation, lint rules, and future non-TypeScript
|
|
8
|
+
* implementations all share the same heuristic.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function _inferStripeApiName(context: MetadataInferenceContext): string;
|
|
13
|
+
/**
|
|
14
|
+
* Infers a sentence-case display name from a declaration's logical name.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare function inferStripeDisplayName(context: MetadataInferenceContext): string;
|
|
19
|
+
/**
|
|
20
|
+
* Derives plural metadata values using the shared `inflected` inflector.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export declare function pluralizeStripeMetadata(context: MetadataPluralizationContext): string;
|
|
25
|
+
/**
|
|
26
|
+
* Stripe metadata policy for FormSpec schema generation.
|
|
27
|
+
*
|
|
28
|
+
* Singular `apiName` and `displayName` values are inferred whenever they are
|
|
29
|
+
* absent. Type declarations also get inferred plural forms so custom-object
|
|
30
|
+
* and extension tooling can share the same resolved metadata contract.
|
|
31
|
+
*
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
export declare const _stripeMetadataPolicy: MetadataPolicyInput;
|
|
35
|
+
//# sourceMappingURL=metadata-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata-policy.d.ts","sourceRoot":"","sources":["../../src/naming/metadata-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,4BAA4B,EAC5B,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAIxB;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAE7E;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAEhF;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,4BAA4B,GAAG,MAAM,CAErF;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,mBAuCnC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Tokenizes an identifier into words using Stripe API case heuristics. @internal */
|
|
2
|
+
export declare function _tokenizeIdentifier(input: string): string[];
|
|
3
|
+
/** Converts an identifier into Stripe API case. @internal */
|
|
4
|
+
export declare function _toStripeApiCase(input: string): string;
|
|
5
|
+
/** Converts an identifier into a sentence-case display name. @internal */
|
|
6
|
+
export declare function _toSentenceDisplayName(input: string): string;
|
|
7
|
+
/** Truncates a name to a maximum length without additional normalization. @internal */
|
|
8
|
+
export declare function _truncateName(value: string, maxLength: number): string;
|
|
9
|
+
//# sourceMappingURL=stripe-api-case.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-api-case.d.ts","sourceRoot":"","sources":["../../src/naming/stripe-api-case.ts"],"names":[],"mappings":"AA4GA,qFAAqF;AACrF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAO3D;AAED,6DAA6D;AAC7D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKtD;AAED,0EAA0E;AAC1E,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAuB5D;AAED,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEtE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation result for an inferred or explicit name.
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export interface _ApiNameValidationResult {
|
|
6
|
+
/** Whether the name passes all validation rules. */
|
|
7
|
+
valid: boolean;
|
|
8
|
+
/** Human-readable messages describing each validation failure. */
|
|
9
|
+
reasons: string[];
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/naming/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,oDAAoD;IACpD,KAAK,EAAE,OAAO,CAAC;IACf,kEAAkE;IAClE,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { _ApiNameValidationResult } from './types.js';
|
|
2
|
+
/** Validates a Stripe API name. @internal */
|
|
3
|
+
export declare function _validateApiName(value: string): _ApiNameValidationResult;
|
|
4
|
+
/** Validates a display name. @internal */
|
|
5
|
+
export declare function _validateDisplayName(value: string): _ApiNameValidationResult;
|
|
6
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/naming/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D,6CAA6C;AAC7C,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,wBAAwB,CA6BxE;AAED,0CAA0C;AAC1C,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,wBAAwB,CAa5E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem-backed TemplateFS implementation
|
|
3
|
+
*
|
|
4
|
+
* Creates a `_TemplateFS` that reads files from the real filesystem at runtime.
|
|
5
|
+
* Suitable for ESM tooling contexts where the templates directory is available
|
|
6
|
+
* on disk.
|
|
7
|
+
*/
|
|
8
|
+
import type { _TemplateFS } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Create a TemplateFS instance rooted at the given directory.
|
|
11
|
+
*
|
|
12
|
+
* Each Mustache render call passes a per-call escape config so that no global
|
|
13
|
+
* Mustache state is mutated. Because we generate source code (not HTML), HTML
|
|
14
|
+
* escaping is intentionally disabled.
|
|
15
|
+
*
|
|
16
|
+
* @param templateDir - Root directory. Defaults to `process.cwd()`.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare function _createFilesystemTemplateFS(templateDir?: string): _TemplateFS;
|
|
20
|
+
//# sourceMappingURL=filesystem-fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem-fs.d.ts","sourceRoot":"","sources":["../../src/templates/filesystem-fs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,GAAE,MAAsB,GAClC,WAAW,CAiBb"}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generator abstraction for composable code generation
|
|
3
|
+
*
|
|
4
|
+
* A generator combines a `files/` directory tree of Mustache templates,
|
|
5
|
+
* a `locals()` function that computes template variables, and optional
|
|
6
|
+
* lifecycle hooks for side effects (manifest updates, config changes).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Generator context for a standalone (non-project) invocation.
|
|
10
|
+
* The generator places files relative to `targetDir`.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export interface _StandaloneGeneratorContext {
|
|
14
|
+
readonly scope: 'standalone';
|
|
15
|
+
readonly targetDir: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generator context for a project-scoped invocation.
|
|
19
|
+
* The generator places files relative to `projectRoot`.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export interface _ProjectGeneratorContext {
|
|
23
|
+
readonly scope: 'project';
|
|
24
|
+
readonly projectRoot: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Discriminated union of the two generator context shapes.
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export type _GeneratorContext = _StandaloneGeneratorContext | _ProjectGeneratorContext;
|
|
31
|
+
/**
|
|
32
|
+
* Capability mixin that adds `writeFiles` to an execute context.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export interface _WriteCapability {
|
|
36
|
+
/** Write generated files to disk. Provided by the caller. */
|
|
37
|
+
writeFiles(files: readonly _PlannedFile[]): Promise<_GeneratorWriteResult>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Execute context for standalone generators.
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export type _StandaloneExecuteContext = _StandaloneGeneratorContext & _WriteCapability;
|
|
44
|
+
/**
|
|
45
|
+
* Execute context for project-scoped generators.
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export type _ProjectExecuteContext = _ProjectGeneratorContext & _WriteCapability;
|
|
49
|
+
/**
|
|
50
|
+
* Discriminated union of the two execute context shapes.
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
export type _GeneratorExecuteContext = _StandaloneExecuteContext | _ProjectExecuteContext;
|
|
54
|
+
/**
|
|
55
|
+
* A single file that a generator intends to create.
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
export interface _PlannedFile {
|
|
59
|
+
readonly path: string;
|
|
60
|
+
readonly content: string;
|
|
61
|
+
/**
|
|
62
|
+
* Human-readable explanation of what this file is and why it is being
|
|
63
|
+
* created. Rendered from the generator's `descriptions` map using Mustache.
|
|
64
|
+
*/
|
|
65
|
+
readonly description?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Structured result returned by a `beforeExecute` hook.
|
|
69
|
+
*
|
|
70
|
+
* Returning `{ proceed: false, reason: '...', remediation: '...' }` is a
|
|
71
|
+
* normal rejection — the user should fix their input. Throwing indicates a
|
|
72
|
+
* generator defect and should be filed as a bug.
|
|
73
|
+
*
|
|
74
|
+
* The discriminated union enforces that `reason` is always present when
|
|
75
|
+
* `proceed` is `false` — `{ proceed: false }` without a reason is a type error.
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
export type _BeforeExecuteResult = {
|
|
79
|
+
readonly proceed: true;
|
|
80
|
+
} | {
|
|
81
|
+
readonly proceed: false;
|
|
82
|
+
readonly reason: string;
|
|
83
|
+
readonly remediation?: string;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Structured result returned by an `afterExecute` hook.
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
export interface _AfterExecuteResult {
|
|
90
|
+
/** Descriptions of side effects that were performed. */
|
|
91
|
+
readonly sideEffects?: readonly string[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Error detail attached to a file write outcome.
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
export interface _WriteError {
|
|
98
|
+
readonly kind: 'permission' | 'disk' | 'conflict' | 'unknown';
|
|
99
|
+
readonly message: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Outcome of writing a single planned file to disk.
|
|
103
|
+
* @internal
|
|
104
|
+
*/
|
|
105
|
+
export interface _FileWriteOutcome {
|
|
106
|
+
readonly path: string;
|
|
107
|
+
readonly decision: 'created' | 'overwritten' | 'skipped' | 'identical';
|
|
108
|
+
readonly proposedContent: string;
|
|
109
|
+
readonly previousContent?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Present only when `decision` is `'skipped'` due to an error (not user choice).
|
|
112
|
+
* For permission errors, disk errors, etc. Not present on 'created', 'overwritten', or 'identical'.
|
|
113
|
+
*/
|
|
114
|
+
readonly error?: _WriteError;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Result of writing all planned files to disk.
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
export interface _GeneratorWriteResult {
|
|
121
|
+
readonly fileOutcomes: readonly _FileWriteOutcome[];
|
|
122
|
+
readonly aborted: boolean;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Result of `_GeneratorRunner.plan()`.
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
export interface _GeneratorPlanResult {
|
|
129
|
+
/** Files that would be generated. */
|
|
130
|
+
readonly files: readonly _PlannedFile[];
|
|
131
|
+
/** Preflight results from all `beforeExecute` hooks. */
|
|
132
|
+
readonly preflightResults: readonly _BeforeExecuteResult[];
|
|
133
|
+
/** Descriptions of side effects that `afterExecute` hooks would perform. */
|
|
134
|
+
readonly plannedSideEffects: readonly string[];
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Result returned by `_GeneratorRunner.execute()`.
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
export interface _GeneratorExecuteResult {
|
|
141
|
+
/** Files that were planned (same as plan().files). */
|
|
142
|
+
readonly files: readonly _PlannedFile[];
|
|
143
|
+
/** Preflight results from all `beforeExecute` hooks. */
|
|
144
|
+
readonly preflightResults: readonly _BeforeExecuteResult[];
|
|
145
|
+
/** Descriptions of side effects declared by generators. */
|
|
146
|
+
readonly plannedSideEffects: readonly string[];
|
|
147
|
+
/** The write result from the caller's `writeFiles` callback. Absent (undefined)
|
|
148
|
+
* if a preflight check rejected execution. */
|
|
149
|
+
readonly writeResult: _GeneratorWriteResult | undefined;
|
|
150
|
+
/** Results from all `afterExecute` hooks. */
|
|
151
|
+
readonly afterExecuteResults: readonly _AfterExecuteResult[];
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Thrown when user-provided input is invalid.
|
|
155
|
+
*
|
|
156
|
+
* Intended for use by generator hooks (e.g., `beforeExecute` validation)
|
|
157
|
+
* and consuming code (CLI error handling). The runner itself throws
|
|
158
|
+
* `_GeneratorDefectError` for structural issues.
|
|
159
|
+
*
|
|
160
|
+
* Callers should display the message and `remediation` to the user.
|
|
161
|
+
* @internal
|
|
162
|
+
*/
|
|
163
|
+
export declare class _GeneratorInputError extends Error {
|
|
164
|
+
readonly remediation: string | undefined;
|
|
165
|
+
constructor(message: string, remediation?: string, options?: ErrorOptions);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Thrown when the generator itself is malformed.
|
|
169
|
+
*
|
|
170
|
+
* This indicates a bug in the generator implementation that should be filed
|
|
171
|
+
* and fixed by the generator author.
|
|
172
|
+
* @internal
|
|
173
|
+
*/
|
|
174
|
+
export declare class _GeneratorDefectError extends Error {
|
|
175
|
+
readonly generatorId: string | undefined;
|
|
176
|
+
constructor(message: string, generatorId?: string, options?: ErrorOptions);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* A composable unit of code generation.
|
|
180
|
+
*
|
|
181
|
+
* A generator combines:
|
|
182
|
+
* - A `files/` directory tree of Mustache templates that mirrors the output structure
|
|
183
|
+
* - A `locals()` function that computes template variables from user params
|
|
184
|
+
* - Optional lifecycle hooks for side effects (manifest updates, config changes)
|
|
185
|
+
*
|
|
186
|
+
* @typeParam TParams - User-provided parameters for this generator
|
|
187
|
+
* @internal
|
|
188
|
+
*/
|
|
189
|
+
export interface _Generator<TParams extends object> {
|
|
190
|
+
/**
|
|
191
|
+
* Compute template variables from user-provided params.
|
|
192
|
+
*
|
|
193
|
+
* The returned record serves as the variable scope for both:
|
|
194
|
+
* - `___token___` resolution in file/directory names (structural placement)
|
|
195
|
+
* - `{{token}}` Mustache rendering in .mustache file content
|
|
196
|
+
*
|
|
197
|
+
* Params are the raw user inputs. Locals are the transformed, computed
|
|
198
|
+
* fields derived from params (e.g., PascalCase, snake_case, pluralized
|
|
199
|
+
* forms, default values). All template surfaces consume from locals.
|
|
200
|
+
*
|
|
201
|
+
* Path tokens (`___token___`) must resolve to strings.
|
|
202
|
+
* Content tokens (`{{token}}`) may be any Mustache-compatible value.
|
|
203
|
+
*/
|
|
204
|
+
locals(params: TParams): Record<string, unknown>;
|
|
205
|
+
/**
|
|
206
|
+
* Root directory of this generator (parent of the `files/` subdirectory).
|
|
207
|
+
* The runner will look for templates under `<filesDir>/files/`.
|
|
208
|
+
*/
|
|
209
|
+
readonly filesDir: string;
|
|
210
|
+
/**
|
|
211
|
+
* Map of template-relative file paths to human-readable descriptions.
|
|
212
|
+
*
|
|
213
|
+
* Keys are the literal filename in the `files/` tree (with `___token___`
|
|
214
|
+
* intact, e.g., `'___objectName___.object.ts.mustache'`). Values may use
|
|
215
|
+
* Mustache `{{token}}` syntax and are rendered with the generator's locals.
|
|
216
|
+
*
|
|
217
|
+
* Example:
|
|
218
|
+
* ```typescript
|
|
219
|
+
* descriptions: {
|
|
220
|
+
* '___objectName___.object.ts.mustache': 'Defines the {{className}} custom object',
|
|
221
|
+
* }
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
readonly descriptions?: Readonly<Record<string, string>>;
|
|
225
|
+
/**
|
|
226
|
+
* Run before files are generated (e.g., validate preconditions).
|
|
227
|
+
*
|
|
228
|
+
* Return `{ proceed: false, reason: '...', remediation: '...' }` to reject
|
|
229
|
+
* execution with user-actionable guidance.
|
|
230
|
+
*
|
|
231
|
+
* **Throwing** indicates a generator defect, not a user input problem.
|
|
232
|
+
*/
|
|
233
|
+
beforeExecute?(params: TParams, context: _GeneratorContext): Promise<_BeforeExecuteResult>;
|
|
234
|
+
/**
|
|
235
|
+
* Run after files are written (e.g., update manifest, install deps).
|
|
236
|
+
*
|
|
237
|
+
* Returns a structured description of side effects performed.
|
|
238
|
+
*
|
|
239
|
+
* Note: if `afterExecute` throws, files have already been written to disk.
|
|
240
|
+
* The error propagates to the caller. Callers should handle this as a
|
|
241
|
+
* partial-completion scenario.
|
|
242
|
+
*/
|
|
243
|
+
afterExecute?(params: TParams, context: _GeneratorContext, writeResult: _GeneratorWriteResult): Promise<_AfterExecuteResult>;
|
|
244
|
+
/**
|
|
245
|
+
* Return descriptions of side effects that `afterExecute` would perform,
|
|
246
|
+
* parameterized by the current params. Used for dry-run output.
|
|
247
|
+
*
|
|
248
|
+
* Returns a promise so future generators can inspect the filesystem to
|
|
249
|
+
* produce accurate descriptions.
|
|
250
|
+
*/
|
|
251
|
+
describeSideEffects?(params: TParams): Promise<readonly string[]>;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Executes a single `_Generator` (or composite of generators), producing file
|
|
255
|
+
* outputs and running lifecycle hooks.
|
|
256
|
+
*
|
|
257
|
+
* Does NOT write files to disk — that responsibility belongs to the caller.
|
|
258
|
+
*
|
|
259
|
+
* @typeParam TParams - User-provided parameters type
|
|
260
|
+
* @internal
|
|
261
|
+
*/
|
|
262
|
+
export declare class _GeneratorRunner<TParams extends object> {
|
|
263
|
+
#private;
|
|
264
|
+
constructor(generator: _Generator<TParams> | ReadonlyArray<_Generator<TParams>>);
|
|
265
|
+
/**
|
|
266
|
+
* Plan phase — compute all files that would be generated, without writing
|
|
267
|
+
* anything to disk.
|
|
268
|
+
*
|
|
269
|
+
* Also runs `beforeExecute` hooks to collect preflight results, and
|
|
270
|
+
* `describeSideEffects` to surface planned side effects. Neither of these
|
|
271
|
+
* write anything or produce observable external effects during plan.
|
|
272
|
+
*
|
|
273
|
+
* Use this for dry runs, previews, and testing.
|
|
274
|
+
*
|
|
275
|
+
* Validates that all output paths are safe (no `..`, no leading `/`) and
|
|
276
|
+
* that no two generators produce the same output path.
|
|
277
|
+
*
|
|
278
|
+
* @param params - User-provided parameters for the generator
|
|
279
|
+
* @param context - Generator context (standalone or project). Passed to
|
|
280
|
+
* `beforeExecute` hooks. Callers must supply a real context — there is no
|
|
281
|
+
* synthetic plan-time sentinel. For dry-run calls outside of a project,
|
|
282
|
+
* use a standalone context with an appropriate `targetDir`.
|
|
283
|
+
*/
|
|
284
|
+
plan(params: TParams, context: _GeneratorContext): Promise<_GeneratorPlanResult>;
|
|
285
|
+
/**
|
|
286
|
+
* Execute phase — runs the full lifecycle:
|
|
287
|
+
* 1. `plan()` to collect preflight results and planned files
|
|
288
|
+
* 2. If any preflight returned `proceed: false`, return early without writing
|
|
289
|
+
* 3. `context.writeFiles()` to write files to disk (delegated to caller)
|
|
290
|
+
* 4. If the write was aborted, return early without calling `afterExecute`
|
|
291
|
+
* 5. `afterExecute` hooks for all generators with the write result
|
|
292
|
+
*/
|
|
293
|
+
execute(params: TParams, context: _GeneratorExecuteContext): Promise<_GeneratorExecuteResult>;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Compose multiple generators with the same params into a single runner.
|
|
297
|
+
*
|
|
298
|
+
* The composite runner merges all file outputs and runs all lifecycle hooks
|
|
299
|
+
* in declaration order.
|
|
300
|
+
*
|
|
301
|
+
* @typeParam TParams - Shared user-provided parameters type
|
|
302
|
+
* @internal
|
|
303
|
+
*/
|
|
304
|
+
export declare function _compositeGenerator<TParams extends object>(...generators: ReadonlyArray<_Generator<TParams>>): _GeneratorRunner<TParams>;
|
|
305
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/templates/generator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,KAAK,EAAE,SAAS,CA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C,UAAU,CAAC,OAAO,CAAC,CAAC;IAI/E;;;;;;;;;;;;;;;;;;OAkBG;IACG,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAwHtF;;;;;;;OAOG;IACG,OAAO,CACX,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC;CAiDpC;AA2CD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,SAAS,MAAM,EACxD,GAAG,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAChD,gBAAgB,CAAC,OAAO,CAAC,CAE3B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory TemplateFS implementation
|
|
3
|
+
*
|
|
4
|
+
* Provides template access from an in-memory image instead of the filesystem.
|
|
5
|
+
* This enables bundled contexts (like pkg) to use templates without runtime
|
|
6
|
+
* filesystem access.
|
|
7
|
+
*/
|
|
8
|
+
import type { _TemplateFS } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Template entry in the in-memory registry
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export interface _TemplateFSImageEntry {
|
|
14
|
+
path: string;
|
|
15
|
+
content: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Extended TemplateFS with directory scanning helpers
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export interface _InMemoryTemplateFS extends _TemplateFS {
|
|
22
|
+
/**
|
|
23
|
+
* Get all template paths under a given directory prefix
|
|
24
|
+
* @internal - For future directory scanning support
|
|
25
|
+
*/
|
|
26
|
+
_getPathsUnder(prefix: string): string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create an in-memory TemplateFS instance
|
|
30
|
+
*
|
|
31
|
+
* Caller must provide exact paths including any base path prefix.
|
|
32
|
+
* For example, to read "extensions/common/tsconfig.json", pass:
|
|
33
|
+
* fs.textFile('extensions', 'common', 'tsconfig.json')
|
|
34
|
+
*
|
|
35
|
+
* Or use scope() to create a scoped instance:
|
|
36
|
+
* fs.scope('extensions').textFile('common', 'tsconfig.json')
|
|
37
|
+
*
|
|
38
|
+
* @param image - Array of template entries with path and content
|
|
39
|
+
* @param pathPrefix - Optional path prefix to prepend to all operations
|
|
40
|
+
* @returns TemplateFS instance that reads from in-memory image
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export declare function _createInMemoryTemplateFS(image: _TemplateFSImageEntry[], pathPrefix?: string): _InMemoryTemplateFS;
|
|
44
|
+
//# sourceMappingURL=in-memory-fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory-fs.d.ts","sourceRoot":"","sources":["../../src/templates/in-memory-fs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC1C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,qBAAqB,EAAE,EAC9B,UAAU,GAAE,MAAW,GACtB,mBAAmB,CA8CrB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template System Core
|
|
3
|
+
*
|
|
4
|
+
* Generic, type-safe template system for code generation.
|
|
5
|
+
* Provides core types, managers, and in-memory filesystem abstraction.
|
|
6
|
+
*
|
|
7
|
+
* Higher-level concerns (file writing, diff viewing, overwrite prompting)
|
|
8
|
+
* remain in `@stripe/extensibility-dev-tools`.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
/** @internal */
|
|
13
|
+
export type { _GeneratedFile, _TemplateOutput, _TemplateFS, _TemplateContext, _Template, } from './types.js';
|
|
14
|
+
/** @internal */
|
|
15
|
+
export { _TemplateManager } from './template-manager.js';
|
|
16
|
+
/** @internal */
|
|
17
|
+
export { _createSimpleTemplate, _SingleTemplateManager, _createSimpleSingleFileTemplate, } from './simple-templates.js';
|
|
18
|
+
/** @internal */
|
|
19
|
+
export { _createInMemoryTemplateFS } from './in-memory-fs.js';
|
|
20
|
+
/** @internal */
|
|
21
|
+
export type { _TemplateFSImageEntry, _InMemoryTemplateFS } from './in-memory-fs.js';
|
|
22
|
+
/** @internal */
|
|
23
|
+
export { _createFilesystemTemplateFS } from './filesystem-fs.js';
|
|
24
|
+
/** @internal */
|
|
25
|
+
export { _GeneratorRunner, _compositeGenerator, _GeneratorInputError, _GeneratorDefectError, } from './generator.js';
|
|
26
|
+
/** @internal */
|
|
27
|
+
export type { _Generator, _GeneratorContext, _StandaloneGeneratorContext, _ProjectGeneratorContext, _WriteCapability, _StandaloneExecuteContext, _ProjectExecuteContext, _GeneratorExecuteContext, _PlannedFile, _BeforeExecuteResult, _AfterExecuteResult, _WriteError, _FileWriteOutcome, _GeneratorWriteResult, _GeneratorPlanResult, _GeneratorExecuteResult, } from './generator.js';
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,gBAAgB;AAChB,YAAY,EACV,cAAc,EACd,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,SAAS,GACV,MAAM,YAAY,CAAC;AAGpB,gBAAgB;AAChB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,gBAAgB;AAChB,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,+BAA+B,GAChC,MAAM,uBAAuB,CAAC;AAG/B,gBAAgB;AAChB,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,gBAAgB;AAChB,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGpF,gBAAgB;AAChB,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAGjE,gBAAgB;AAChB,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,gBAAgB;AAChB,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,wBAAwB,EACxB,gBAAgB,EAChB,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC"}
|