@stripe/extensibility-jsonschema-tools 0.6.3
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/extensibility-jsonschema-tools-alpha.d.ts +2598 -0
- package/dist/extensibility-jsonschema-tools-beta.d.ts +2598 -0
- package/dist/extensibility-jsonschema-tools-internal.d.ts +2761 -0
- package/dist/extensibility-jsonschema-tools-public.d.ts +2598 -0
- package/dist/extract-config-schemas.d.ts +110 -0
- package/dist/extract-config-schemas.d.ts.map +1 -0
- package/dist/fixup-decimal-path-constraints.d.ts +13 -0
- package/dist/fixup-decimal-path-constraints.d.ts.map +1 -0
- package/dist/generate-schemas.d.ts +12 -0
- package/dist/generate-schemas.d.ts.map +1 -0
- package/dist/index.cjs +20599 -0
- package/dist/index.d.cts +2839 -0
- package/dist/index.d.ts +2839 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20555 -0
- package/dist/stdlib-extension.d.ts +47 -0
- package/dist/stdlib-extension.d.ts.map +1 -0
- package/dist/stripe-formspec-config.d.ts +16 -0
- package/dist/stripe-formspec-config.d.ts.map +1 -0
- package/dist/stripe-schema-defaults.d.ts +14 -0
- package/dist/stripe-schema-defaults.d.ts.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract config type schemas from extension class exports.
|
|
3
|
+
*
|
|
4
|
+
* Given a file path and export name, resolves the class declaration,
|
|
5
|
+
* walks its `implements` clause to find generic type arguments, and
|
|
6
|
+
* extracts JSON Schema + UI Schema from each config type.
|
|
7
|
+
*/
|
|
8
|
+
import type { JsonSchema2020, UISchema } from '@formspec/build';
|
|
9
|
+
/**
|
|
10
|
+
* Options for extracting config schemas from a class export.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export interface _ExtractConfigSchemasOptions {
|
|
15
|
+
/** Absolute path to the TypeScript source file */
|
|
16
|
+
filePath: string;
|
|
17
|
+
/**
|
|
18
|
+
* Export name to resolve. Use `"default"` for the file's default export,
|
|
19
|
+
* or a named export identifier (e.g., `"LoyaltyDiscount"`).
|
|
20
|
+
*/
|
|
21
|
+
exportName: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* UI schema describing how to render a configuration form.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export type _ConfigUiSchema = UISchema;
|
|
29
|
+
/**
|
|
30
|
+
* A single config schema extracted from a generic type argument.
|
|
31
|
+
*
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
export interface _ConfigSchemaResult {
|
|
35
|
+
/** Name of the interface whose generic type argument was resolved */
|
|
36
|
+
interfaceName: string;
|
|
37
|
+
/** Name of the resolved config type */
|
|
38
|
+
typeName: string;
|
|
39
|
+
/** Absolute path to the source file that defines the config type */
|
|
40
|
+
sourceFilePath: string;
|
|
41
|
+
/** JSON Schema for validation */
|
|
42
|
+
jsonSchema: JsonSchema2020;
|
|
43
|
+
/** UI Schema for rendering */
|
|
44
|
+
uiSchema: _ConfigUiSchema;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Result of extracting config schemas from a class export.
|
|
48
|
+
*
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export interface _ExtractConfigSchemasResult {
|
|
52
|
+
/** Config schemas extracted from the class's `implements` clauses */
|
|
53
|
+
schemas: _ConfigSchemaResult[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A resolved type argument from an `implements` clause.
|
|
57
|
+
*
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
export interface _ConfigTypeRef {
|
|
61
|
+
/** Name of the interface whose generic type argument was resolved */
|
|
62
|
+
interfaceName: string;
|
|
63
|
+
/** Name of the resolved config type */
|
|
64
|
+
typeName: string;
|
|
65
|
+
/** Absolute path to the source file that defines the config type */
|
|
66
|
+
sourceFilePath: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Resolves the generic type arguments from a class's `implements` clause.
|
|
70
|
+
*
|
|
71
|
+
* Given a file and export name, this function:
|
|
72
|
+
* 1. Resolves the exported class declaration
|
|
73
|
+
* 2. Walks its `implements` clauses to find generic type arguments
|
|
74
|
+
* 3. Returns a `ConfigTypeRef` for each resolved type argument
|
|
75
|
+
*
|
|
76
|
+
* Primitive and anonymous type arguments (no resolvable symbol) are silently
|
|
77
|
+
* skipped. Use this when you need the type locations but not the JSON Schema.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* // Given: export class LoyaltyDiscount implements DiscountCalculation<LoyaltyDiscountConfig>
|
|
82
|
+
* const refs = resolveConfigTypeArgs({ filePath: '...', exportName: 'default' });
|
|
83
|
+
* // refs[0].typeName === 'LoyaltyDiscountConfig'
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @param options - File path and export name
|
|
87
|
+
* @returns Array of resolved config type references
|
|
88
|
+
* @throws If the export name is not found (lists available exports).
|
|
89
|
+
* @throws If the export exists but is not a class declaration.
|
|
90
|
+
*
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
export declare function _resolveConfigTypeArgs(options: _ExtractConfigSchemasOptions): _ConfigTypeRef[];
|
|
94
|
+
/**
|
|
95
|
+
* Extracts config schemas from the generic type arguments in a class's
|
|
96
|
+
* `implements` clause.
|
|
97
|
+
*
|
|
98
|
+
* Calls `resolveConfigTypeArgs` then runs `generateSchemas` on each result.
|
|
99
|
+
* Use `resolveConfigTypeArgs` directly when you need the type locations but
|
|
100
|
+
* not the JSON Schema.
|
|
101
|
+
*
|
|
102
|
+
* @param options - File path and export name
|
|
103
|
+
* @returns Envelope containing an array of config schema results
|
|
104
|
+
* @throws If the export name is not found (lists available exports).
|
|
105
|
+
* @throws If the export exists but is not a class declaration.
|
|
106
|
+
*
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
export declare function _extractConfigSchemas(options: _ExtractConfigSchemasOptions): _ExtractConfigSchemasResult;
|
|
110
|
+
//# sourceMappingURL=extract-config-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-config-schemas.d.ts","sourceRoot":"","sources":["../src/extract-config-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAOhE;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;AAEvC;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,qEAAqE;IACrE,aAAa,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,cAAc,EAAE,MAAM,CAAC;IACvB,iCAAiC;IACjC,UAAU,EAAE,cAAc,CAAC;IAC3B,8BAA8B;IAC9B,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C,qEAAqE;IACrE,OAAO,EAAE,mBAAmB,EAAE,CAAC;CAChC;AAkBD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,qEAAqE;IACrE,aAAa,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,cAAc,EAAE,MAAM,CAAC;CACxB;AA2BD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,4BAA4B,GACpC,cAAc,EAAE,CAqDlB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,4BAA4B,GACpC,2BAA2B,CAc7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JsonSchema2020 } from '@formspec/build';
|
|
2
|
+
/**
|
|
3
|
+
* Post-processes a generated JSON Schema to fix path-targeted constraints on
|
|
4
|
+
* Decimal sub-properties. Mutates the schema in place for efficiency.
|
|
5
|
+
*
|
|
6
|
+
* When formspec emits `$ref` + sibling `properties` for path-targeted
|
|
7
|
+
* constraints, any numeric constraint keywords targeting a Decimal sub-property
|
|
8
|
+
* must be broadened to the corresponding `decimal*` keyword with a string value.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function _fixupDecimalPathConstraints(schema: JsonSchema2020): JsonSchema2020;
|
|
13
|
+
//# sourceMappingURL=fixup-decimal-path-constraints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixup-decimal-path-constraints.d.ts","sourceRoot":"","sources":["../src/fixup-decimal-path-constraints.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AActD;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAgBnF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type GenerateSchemasOptions } from '@formspec/build';
|
|
2
|
+
/**
|
|
3
|
+
* Generates JSON Schema and UI Schema using Stripe's canonical config.
|
|
4
|
+
*
|
|
5
|
+
* Passes {@link _stripeFormSpecConfig} via the `config` field so formspec's
|
|
6
|
+
* internal `resolveOptions` handles extension registry, metadata policy,
|
|
7
|
+
* and enum serialization consistently.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function _generateSchemas(options: Omit<GenerateSchemasOptions, 'errorReporting'>): import("@formspec/build").GenerateFromClassResult;
|
|
12
|
+
//# sourceMappingURL=generate-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-schemas.d.ts","sourceRoot":"","sources":["../src/generate-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,iBAAiB,CAAC;AAIzB;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,IAAI,CAAC,sBAAsB,EAAE,gBAAgB,CAAC,qDAoBxD"}
|