@swarm.ing/pieui 2.0.23 → 2.0.25
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/dist/__tests__/step6-card-add-from.test.d.cts +2 -0
- package/dist/__tests__/step6-card-add-from.test.d.cts.map +1 -0
- package/dist/cli.js +2962 -1139
- package/dist/code/args.d.ts +1 -1
- package/dist/code/args.d.ts.map +1 -1
- package/dist/code/commands/add.d.ts.map +1 -1
- package/dist/code/commands/addEvent.d.ts.map +1 -1
- package/dist/code/commands/cardAddFromMeta.d.ts +4 -0
- package/dist/code/commands/cardAddFromMeta.d.ts.map +1 -0
- package/dist/code/commands/cardCheckSync.d.ts +2 -0
- package/dist/code/commands/cardCheckSync.d.ts.map +1 -0
- package/dist/code/commands/cardDumpMetadata.d.ts +39 -0
- package/dist/code/commands/cardDumpMetadata.d.ts.map +1 -0
- package/dist/code/commands/create.d.ts.map +1 -1
- package/dist/code/commands/createPieApp.d.ts.map +1 -1
- package/dist/code/commands/init.d.ts.map +1 -1
- package/dist/code/commands/pageAdd.d.ts.map +1 -1
- package/dist/code/commands/remove.d.ts.map +1 -1
- package/dist/code/commands/selfUpgrade.d.ts +2 -0
- package/dist/code/commands/selfUpgrade.d.ts.map +1 -0
- package/dist/code/introspection/collectFiles.d.ts +27 -0
- package/dist/code/introspection/collectFiles.d.ts.map +1 -0
- package/dist/code/introspection/errors.d.ts +32 -0
- package/dist/code/introspection/errors.d.ts.map +1 -0
- package/dist/code/introspection/extractEvents.d.ts +33 -0
- package/dist/code/introspection/extractEvents.d.ts.map +1 -0
- package/dist/code/introspection/extractEventsPayloads.d.ts +94 -0
- package/dist/code/introspection/extractEventsPayloads.d.ts.map +1 -0
- package/dist/code/introspection/extractImports.d.ts +46 -0
- package/dist/code/introspection/extractImports.d.ts.map +1 -0
- package/dist/code/introspection/findDataType.d.ts +59 -0
- package/dist/code/introspection/findDataType.d.ts.map +1 -0
- package/dist/code/introspection/findInputType.d.ts +42 -0
- package/dist/code/introspection/findInputType.d.ts.map +1 -0
- package/dist/code/introspection/index.d.ts +47 -0
- package/dist/code/introspection/index.d.ts.map +1 -0
- package/dist/code/introspection/schemaContext.d.ts +69 -0
- package/dist/code/introspection/schemaContext.d.ts.map +1 -0
- package/dist/code/introspection/typeToSchema.d.ts +38 -0
- package/dist/code/introspection/typeToSchema.d.ts.map +1 -0
- package/dist/code/jsonSchemaToTs.d.ts +4 -0
- package/dist/code/jsonSchemaToTs.d.ts.map +1 -0
- package/dist/code/metadataCompare.d.ts +29 -0
- package/dist/code/metadataCompare.d.ts.map +1 -0
- package/dist/code/printRequirements.d.ts +10 -0
- package/dist/code/printRequirements.d.ts.map +1 -0
- package/dist/code/types.d.ts +19 -1
- package/dist/code/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/code/args.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ParsedArgs } from './types';
|
|
2
2
|
export declare const parseArgs: (argv: string[]) => ParsedArgs;
|
|
3
|
-
export type HelpScope = 'all' | 'login' | 'create' | 'init' | 'postbuild' | 'card' | 'card-remote' | 'page';
|
|
3
|
+
export type HelpScope = 'all' | 'login' | 'create' | 'init' | 'postbuild' | 'card' | 'card-remote' | 'page' | 'self-upgrade';
|
|
4
4
|
export declare const detectHelpScope: (argv: string[]) => HelpScope | null;
|
|
5
5
|
export declare const printUsage: (scope?: HelpScope) => void;
|
|
6
6
|
//# sourceMappingURL=args.d.ts.map
|
package/dist/code/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/code/args.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAOR,UAAU,EACb,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/code/args.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAOR,UAAU,EACb,MAAM,SAAS,CAAA;AA8JhB,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,KAAG,UAuI1C,CAAA;AAED,MAAM,MAAM,SAAS,GACf,KAAK,GACL,OAAO,GACP,QAAQ,GACR,MAAM,GACN,WAAW,GACX,MAAM,GACN,aAAa,GACb,MAAM,GACN,cAAc,CAAA;AAEpB,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,EAAE,KAAG,SAAS,GAAG,IAmB5D,CAAA;AAoMD,eAAO,MAAM,UAAU,GAAI,QAAO,SAAiB,SAwBlD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/code/commands/add.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/code/commands/add.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AA8C7D,eAAO,MAAM,UAAU,GACnB,eAAe,MAAM,EACrB,gBAAe,aAAmC,EAClD,UAAS,mBAAwB,SAqGpC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addEvent.d.ts","sourceRoot":"","sources":["../../../src/code/commands/addEvent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"addEvent.d.ts","sourceRoot":"","sources":["../../../src/code/commands/addEvent.ts"],"names":[],"mappings":"AAyFA,eAAO,MAAM,eAAe,GACxB,QAAQ,MAAM,EACd,eAAe,MAAM,EACrB,WAAW,MAAM,SAiJpB,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ComponentType } from '../types';
|
|
2
|
+
export declare const hasBackendSourceFor: (componentName: string) => boolean;
|
|
3
|
+
export declare const cardAddFromMetaCommand: (componentName: string, componentType: ComponentType, fromRaw: string | undefined) => void;
|
|
4
|
+
//# sourceMappingURL=cardAddFromMeta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cardAddFromMeta.d.ts","sourceRoot":"","sources":["../../../src/code/commands/cardAddFromMeta.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAA2B,MAAM,UAAU,CAAA;AAgStE,eAAO,MAAM,mBAAmB,GAAI,eAAe,MAAM,KAAG,OAU3D,CAAA;AAED,eAAO,MAAM,sBAAsB,GAC/B,eAAe,MAAM,EACrB,eAAe,aAAa,EAC5B,SAAS,MAAM,GAAG,SAAS,KAC5B,IA+FF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cardCheckSync.d.ts","sourceRoot":"","sources":["../../../src/code/commands/cardCheckSync.ts"],"names":[],"mappings":"AAmKA,eAAO,MAAM,oBAAoB,GAC7B,eAAe,MAAM,KACtB,OAAO,CAAC,MAAM,CAmBhB,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pieui card dump-metadata <Name>` — emit PieMetadata JSON.
|
|
3
|
+
*
|
|
4
|
+
* This module is the orchestration layer. All introspection algorithms
|
|
5
|
+
* live in `code/introspection/` — see that package's JSDoc for inputs,
|
|
6
|
+
* outputs, and algorithmic assumptions of each piece.
|
|
7
|
+
*/
|
|
8
|
+
import type { PieMetadata } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Build the PieMetadata object for a component.
|
|
11
|
+
*
|
|
12
|
+
* INPUTS:
|
|
13
|
+
* - `componentName`: the PascalCase card name. Must correspond to a
|
|
14
|
+
* directory `<settings.componentsDir>/<componentName>/`.
|
|
15
|
+
*
|
|
16
|
+
* RETURNS: full PieMetadata object (see `types.ts`).
|
|
17
|
+
*
|
|
18
|
+
* ASSUMPTIONS:
|
|
19
|
+
* - The component's data type follows naming convention
|
|
20
|
+
* `<Name>Data` / `I<Name>Data` / `<Name>Props` (see findDataType).
|
|
21
|
+
* - `<PieCard>` JSX usage is the source of truth for events; methods
|
|
22
|
+
* must be an inline object literal (see extractEvents).
|
|
23
|
+
* - Input variant is detected ONLY via `<PieCard stored={X}/>`
|
|
24
|
+
* (see findInputType — policy decision in spec discussion).
|
|
25
|
+
*
|
|
26
|
+
* PIPELINE:
|
|
27
|
+
* 1. Glob component files (collectComponentFiles).
|
|
28
|
+
* 2. Build TS program/checker context (createSchemaContext).
|
|
29
|
+
* 3. Find props data type via naming convention.
|
|
30
|
+
* 4. Extract events strictly from `<PieCard methods={…}>`.
|
|
31
|
+
* 5. Recover each event handler's payload type.
|
|
32
|
+
* 6. Find input type via `<PieCard stored={X}/>`.
|
|
33
|
+
* 7. Split imports into packages / relativeImports.
|
|
34
|
+
*/
|
|
35
|
+
export declare const buildCardMetadata: (componentName: string) => PieMetadata;
|
|
36
|
+
export declare const stringifyPieMetadata: (meta: PieMetadata) => string;
|
|
37
|
+
/** CLI entry point. Builds metadata, writes to `outFile` or stdout. */
|
|
38
|
+
export declare const cardDumpMetadataCommand: (componentName: string, outFile: string | undefined) => void;
|
|
39
|
+
//# sourceMappingURL=cardDumpMetadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cardDumpMetadata.d.ts","sourceRoot":"","sources":["../../../src/code/commands/cardDumpMetadata.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiBH,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,UAAU,CAAA;AAwBvD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,iBAAiB,GAAI,eAAe,MAAM,KAAG,WA6DzD,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,MAAM,WAAW,KAAG,MAChC,CAAA;AAEzB,uEAAuE;AACvE,eAAO,MAAM,uBAAuB,GAChC,eAAe,MAAM,EACrB,SAAS,MAAM,GAAG,SAAS,KAC5B,IAWF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/code/commands/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/code/commands/create.ts"],"names":[],"mappings":"AAgGA,eAAO,MAAM,aAAa,GAAU,SAAS,MAAM,kBAiDlD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPieApp.d.ts","sourceRoot":"","sources":["../../../src/code/commands/createPieApp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createPieApp.d.ts","sourceRoot":"","sources":["../../../src/code/commands/createPieApp.ts"],"names":[],"mappings":"AAuOA,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,SAyElD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/code/commands/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/code/commands/init.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,WAAW,GAAU,QAAQ,MAAM,kBAoH/C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageAdd.d.ts","sourceRoot":"","sources":["../../../src/code/commands/pageAdd.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pageAdd.d.ts","sourceRoot":"","sources":["../../../src/code/commands/pageAdd.ts"],"names":[],"mappings":"AAwDA,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,SAsB9C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/code/commands/remove.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/code/commands/remove.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,aAAa,GAAI,eAAe,MAAM,SAwDlD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selfUpgrade.d.ts","sourceRoot":"","sources":["../../../src/code/commands/selfUpgrade.ts"],"names":[],"mappings":"AAmDA,eAAO,MAAM,kBAAkB,GAAU,WAAW,MAAM,KAAG,OAAO,CAAC,IAAI,CAwCxE,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Glob a component directory for source files relevant to introspection.
|
|
3
|
+
*
|
|
4
|
+
* Excludes everything that's not "real" component code: tests, snapshots,
|
|
5
|
+
* Storybook stories, mocks.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Return absolute paths of `.ts`/`.tsx`/`.css` files belonging to a
|
|
9
|
+
* component, sorted, deduplicated.
|
|
10
|
+
*
|
|
11
|
+
* ASSUMES: `componentDir` is the absolute directory containing the
|
|
12
|
+
* component (e.g. `<cwd>/piecomponents/<Name>`).
|
|
13
|
+
*
|
|
14
|
+
* RETURNS: sorted absolute paths. Empty array if nothing matches.
|
|
15
|
+
*
|
|
16
|
+
* EXCLUDED:
|
|
17
|
+
* - `**/__tests__/**` / `**/__snapshots__/**` / `**/__mocks__/**`
|
|
18
|
+
* - `*.test.{ts,tsx}` / `*.spec.{ts,tsx}`
|
|
19
|
+
* - `*.stories.{ts,tsx}` (Storybook)
|
|
20
|
+
*
|
|
21
|
+
* EDGE CASES:
|
|
22
|
+
* - Files outside `componentDir` are never included.
|
|
23
|
+
* - `.css` files are listed but not parsed by downstream introspection
|
|
24
|
+
* (they go into `files` for completeness).
|
|
25
|
+
*/
|
|
26
|
+
export declare const collectComponentFiles: (componentDir: string) => string[];
|
|
27
|
+
//# sourceMappingURL=collectFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectFiles.d.ts","sourceRoot":"","sources":["../../../src/code/introspection/collectFiles.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,qBAAqB,GAAI,cAAc,MAAM,KAAG,MAAM,EAwBlE,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors raised by TS introspection.
|
|
3
|
+
*
|
|
4
|
+
* Each error carries:
|
|
5
|
+
* - the file being analysed (`sourceFile`)
|
|
6
|
+
* - line/column when available
|
|
7
|
+
* - a stack of contexts describing the location in the structure
|
|
8
|
+
* - actionable hint about how to fix the source
|
|
9
|
+
*
|
|
10
|
+
* These propagate to the CLI without being caught — the whole point
|
|
11
|
+
* of the strict model is to surface unknown shapes loudly.
|
|
12
|
+
*/
|
|
13
|
+
export type IntrospectionErrorOptions = {
|
|
14
|
+
sourceFile?: string;
|
|
15
|
+
line?: number;
|
|
16
|
+
column?: number;
|
|
17
|
+
context?: string[];
|
|
18
|
+
hint?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare class IntrospectionError extends Error {
|
|
21
|
+
sourceFile?: string;
|
|
22
|
+
line?: number;
|
|
23
|
+
column?: number;
|
|
24
|
+
context: string[];
|
|
25
|
+
hint?: string;
|
|
26
|
+
constructor(message: string, opts?: IntrospectionErrorOptions);
|
|
27
|
+
/** Push a context frame and return self (for try/catch rethrow). */
|
|
28
|
+
withContext(frame: string): IntrospectionError;
|
|
29
|
+
private bareMessage;
|
|
30
|
+
}
|
|
31
|
+
export declare const errorOptsFromNode: (sourceFile: any, node: any) => IntrospectionErrorOptions;
|
|
32
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/code/introspection/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,yBAAyB,GAAG;IACpC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IACzC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;gBAED,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,yBAA8B;IAyBjE,oEAAoE;IACpE,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB;IAc9C,OAAO,CAAC,WAAW;CAWtB;AAkBD,eAAO,MAAM,iBAAiB,GAC1B,YAAY,GAAG,EACf,MAAM,GAAG,KACV,yBAGD,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strict extraction of event names from `<PieCard methods={…}>` JSX.
|
|
3
|
+
*
|
|
4
|
+
* The contract is intentionally STRICT (asymmetric to the lenient
|
|
5
|
+
* Python side): `methods={…}` MUST be an inline object literal with
|
|
6
|
+
* static keys. Spread, variable references, computed keys → throws.
|
|
7
|
+
*
|
|
8
|
+
* Rationale: TS authors who pass `methods={pieMethods}` (a hook return)
|
|
9
|
+
* have no way for static analysis to know the event surface. We force
|
|
10
|
+
* the call site to spell out the keys so the registry is observable.
|
|
11
|
+
*
|
|
12
|
+
* Use case: produces the `events` field of PieMetadata.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Extract the union of event names declared via `<PieCard methods={…}>`
|
|
16
|
+
* across the given files.
|
|
17
|
+
*
|
|
18
|
+
* ASSUMES: `files` are absolute paths to `.ts`/`.tsx` source files.
|
|
19
|
+
*
|
|
20
|
+
* RETURNS: sorted array of unique event names (object-literal keys).
|
|
21
|
+
*
|
|
22
|
+
* THROWS: Error with file:line if `methods={…}` is anything other than
|
|
23
|
+
* a plain inline object literal with static keys. Specifically:
|
|
24
|
+
* - `methods={spread}` (Identifier initializer) — throws.
|
|
25
|
+
* - `methods={{ ...other }}` (spread element) — throws.
|
|
26
|
+
* - `methods={{ [key]: handler }}` (computed key) — throws.
|
|
27
|
+
* - `methods={{ click: fn }}` (PropertyAssignment) — OK.
|
|
28
|
+
* - `methods={{ click }}` (Shorthand) — OK, key is `"click"`.
|
|
29
|
+
*
|
|
30
|
+
* Strings ARE accepted as keys (`methods={{ "click-x": fn }}`).
|
|
31
|
+
*/
|
|
32
|
+
export declare const extractEvents: (files: string[]) => string[];
|
|
33
|
+
//# sourceMappingURL=extractEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractEvents.d.ts","sourceRoot":"","sources":["../../../src/code/introspection/extractEvents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAoGH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,KAAG,MAAM,EA2DrD,CAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recover the TS type of each event handler's first parameter, then
|
|
3
|
+
* produce `eventsPropsCode` (source text) and `eventsPropsSchema` (JSON
|
|
4
|
+
* Schema) for use in PieMetadata.
|
|
5
|
+
*
|
|
6
|
+
* Event handlers can be declared in three forms — all are handled here:
|
|
7
|
+
*
|
|
8
|
+
* 1. Inline arrow / function expression:
|
|
9
|
+
* methods={{ click: (e: ClickEvt) => doIt(e) }}
|
|
10
|
+
*
|
|
11
|
+
* 2. Shorthand property whose name matches a variable in scope:
|
|
12
|
+
* const click = (e: ClickEvt) => doIt(e)
|
|
13
|
+
* methods={{ click }}
|
|
14
|
+
*
|
|
15
|
+
* 3. Method declaration:
|
|
16
|
+
* methods={{ click(e: ClickEvt) { doIt(e) } }}
|
|
17
|
+
*
|
|
18
|
+
* In all three the parameter's type annotation is the source of truth.
|
|
19
|
+
*/
|
|
20
|
+
import { type SchemaContext } from './schemaContext';
|
|
21
|
+
import type { JSONSchema } from '../types';
|
|
22
|
+
/**
|
|
23
|
+
* Follow a JSX shorthand or identifier reference back to the function
|
|
24
|
+
* declaration and return its first parameter node.
|
|
25
|
+
*
|
|
26
|
+
* ASSUMES: `identifier` is an AST `Identifier` node.
|
|
27
|
+
*
|
|
28
|
+
* RETURNS: the `Parameter` AST node, or `null` if:
|
|
29
|
+
* - the symbol can't be resolved by the checker.
|
|
30
|
+
* - the declaration isn't a function-like form we recognize.
|
|
31
|
+
*
|
|
32
|
+
* RESOLVES:
|
|
33
|
+
* - `FunctionDeclaration` — `function foo(p) {}`
|
|
34
|
+
* - `VariableDeclaration` initializer = ArrowFunction/FunctionExpr
|
|
35
|
+
* — `const foo = (p) => …`
|
|
36
|
+
* - `MethodDeclaration` / `MethodSignature`
|
|
37
|
+
* - Alias symbols (re-exports) are unwrapped via `getAliasedSymbol`.
|
|
38
|
+
*
|
|
39
|
+
* KNOWN GAPS: `useCallback(fn)`, type-asserted (`fn as F`), wrapped in
|
|
40
|
+
* `useMemo` etc. — these reach a non-recognized declaration and return
|
|
41
|
+
* `null`. The event still appears in `events[]` but its schema/code
|
|
42
|
+
* stays empty.
|
|
43
|
+
*/
|
|
44
|
+
export declare const followIdentifierToFunction: (ctx: SchemaContext, identifier: any) => any | null;
|
|
45
|
+
/**
|
|
46
|
+
* Render a function parameter as `{ code, schema }`.
|
|
47
|
+
*
|
|
48
|
+
* ASSUMES: `parameter` is an AST `Parameter` node; `sourceFile` is the
|
|
49
|
+
* `SourceFile` containing it (for `getText` to return original text).
|
|
50
|
+
*
|
|
51
|
+
* RETURNS:
|
|
52
|
+
* - `code`: the explicit type annotation if present (e.g.
|
|
53
|
+
* `"{ tab: string }"`), or the checker-inferred type as a string
|
|
54
|
+
* when the parameter is untyped.
|
|
55
|
+
* - `schema`: JSON Schema. Strategy:
|
|
56
|
+
* 1. If annotation is a `TypeReferenceNode` (`Foo`) — try
|
|
57
|
+
* `buildSchemaForType(ctx, "Foo")` (via typescript-json-schema).
|
|
58
|
+
* 2. Otherwise — fall back to `typeToSchema(checker.getTypeAtLocation(typeNode))`
|
|
59
|
+
* which walks the TS Type directly (handles inline literals).
|
|
60
|
+
* - `null` schema when neither path produces a result.
|
|
61
|
+
*/
|
|
62
|
+
export declare const schemaForParameter: (ctx: SchemaContext, parameter: any, sourceFile: any) => {
|
|
63
|
+
code: string;
|
|
64
|
+
schema: JSONSchema | null;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Walk `<PieCard methods={…}>` JSX literals in every file, restrict to
|
|
68
|
+
* the previously-extracted `events` set, and recover each handler's
|
|
69
|
+
* parameter type as `{ code, schema }`.
|
|
70
|
+
*
|
|
71
|
+
* ASSUMES:
|
|
72
|
+
* - `events` is the list of event-name strings already discovered by
|
|
73
|
+
* `extractEvents` (which itself enforces the inline-object-literal
|
|
74
|
+
* rule). This pass tolerates the same shape — anything else is
|
|
75
|
+
* skipped without throwing.
|
|
76
|
+
* - `ctx` includes all `files` (so `getSourceFile()` succeeds).
|
|
77
|
+
*
|
|
78
|
+
* RETURNS:
|
|
79
|
+
* - `code`: `{ eventName: typeText }`. May be empty for events whose
|
|
80
|
+
* handler can't be statically resolved (e.g. `useCallback`-wrapped).
|
|
81
|
+
* - `schema`: `{ eventName: JSONSchema }`. Same caveat.
|
|
82
|
+
*
|
|
83
|
+
* EDGE CASES:
|
|
84
|
+
* - Spread / variable `methods={…}` is silently skipped here
|
|
85
|
+
* (because `extractEvents` already strictly rejected those, the
|
|
86
|
+
* unreachable case is defensive).
|
|
87
|
+
* - Events listed in `events[]` but not present as keys in the JSX
|
|
88
|
+
* are absent from the result (no synthetic entry).
|
|
89
|
+
*/
|
|
90
|
+
export declare const extractEventsPayloads: (ctx: SchemaContext, files: string[], events: string[]) => {
|
|
91
|
+
code: Record<string, string>;
|
|
92
|
+
schema: Record<string, JSONSchema>;
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=extractEventsPayloads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractEventsPayloads.d.ts","sourceRoot":"","sources":["../../../src/code/introspection/extractEventsPayloads.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAExE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAK1C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,0BAA0B,GACnC,KAAK,aAAa,EAClB,YAAY,GAAG,KAChB,GAAG,GAAG,IAmCR,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,kBAAkB,GAC3B,KAAK,aAAa,EAClB,WAAW,GAAG,EACd,YAAY,GAAG,KAChB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAA;CAsB3C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,qBAAqB,GAC9B,KAAK,aAAa,EAClB,OAAO,MAAM,EAAE,EACf,QAAQ,MAAM,EAAE,KACjB;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CAmGpE,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split a component's import graph into `relativeImports` (project-local
|
|
3
|
+
* file paths) and `packages` (third-party deps with version specs from
|
|
4
|
+
* package.json).
|
|
5
|
+
*
|
|
6
|
+
* Resolution strategy:
|
|
7
|
+
* 1. `ts.resolveModuleName` with a ts.sys-backed host.
|
|
8
|
+
* 2. Manual fallback through `tsconfig.json` paths aliases for cases
|
|
9
|
+
* where Bundler resolution doesn't match (e.g. `@/components/*`).
|
|
10
|
+
*
|
|
11
|
+
* Output classification:
|
|
12
|
+
* - resolved path INSIDE cwd AND NOT under any `node_modules/` →
|
|
13
|
+
* `relativeImports`.
|
|
14
|
+
* - everything else → `packages`, with version copied verbatim from
|
|
15
|
+
* `package.json` deps (dev/peer/optional included) when known.
|
|
16
|
+
*/
|
|
17
|
+
export type ImportSplit = {
|
|
18
|
+
relativeImports: string[];
|
|
19
|
+
packages: string[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Walk imports in each file and classify them.
|
|
23
|
+
*
|
|
24
|
+
* ASSUMES:
|
|
25
|
+
* - `files` are absolute paths.
|
|
26
|
+
* - `cwd` (default: `process.cwd()`) is the project root containing
|
|
27
|
+
* `tsconfig.json` and `package.json`.
|
|
28
|
+
*
|
|
29
|
+
* RETURNS:
|
|
30
|
+
* - `relativeImports`: sorted absolute paths to project-local files.
|
|
31
|
+
* `node_modules` paths are excluded — they're classified as packages.
|
|
32
|
+
* - `packages`: sorted strings ready for `bun add` / `npm install`.
|
|
33
|
+
* Format is either `name` (no version found) or `name@<spec>`
|
|
34
|
+
* where `<spec>` is the verbatim entry from package.json.
|
|
35
|
+
*
|
|
36
|
+
* EDGE CASES:
|
|
37
|
+
* - Symlinks INSIDE cwd → followed to realpath; if realpath is still
|
|
38
|
+
* inside cwd, kept as relativeImport; if outside, dropped as package.
|
|
39
|
+
* - Path-aliased imports (`@/x`) when `paths` is in tsconfig.json:
|
|
40
|
+
* resolved via `resolveByTsconfigPaths` if `ts.resolveModuleName`
|
|
41
|
+
* fails.
|
|
42
|
+
* - Bare specs starting with `.` or `/` that don't resolve to a real
|
|
43
|
+
* file → silently dropped (consumer can't add a missing file).
|
|
44
|
+
*/
|
|
45
|
+
export declare const extractImports: (files: string[], cwd?: string) => ImportSplit;
|
|
46
|
+
//# sourceMappingURL=extractImports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractImports.d.ts","sourceRoot":"","sources":["../../../src/code/introspection/extractImports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA0NH,MAAM,MAAM,WAAW,GAAG;IACtB,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAA;CACrB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,cAAc,GACvB,OAAO,MAAM,EAAE,EACf,MAAK,MAAsB,KAC5B,WA6DF,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locate the TypeScript `<Name>Data` declaration that defines a card's
|
|
3
|
+
* props shape, and the `pathname*` field names within it (ajaxList).
|
|
4
|
+
*
|
|
5
|
+
* The pieui convention: a card named `Foo` has its props described by
|
|
6
|
+
* `interface FooData { ... }`. Alternatives `IFooData` and `FooProps`
|
|
7
|
+
* are also recognized to accommodate older conventions.
|
|
8
|
+
*/
|
|
9
|
+
import { type SchemaContext } from './schemaContext';
|
|
10
|
+
/**
|
|
11
|
+
* Try to find the card's data type by naming convention.
|
|
12
|
+
*
|
|
13
|
+
* ASSUMES: `componentName` is the PascalCase card name (e.g. `BoxCard`).
|
|
14
|
+
*
|
|
15
|
+
* RETURNS: `{ typeName, declaration }` for the first match, or `null`.
|
|
16
|
+
*
|
|
17
|
+
* TYPE NAME CANDIDATES, in priority order:
|
|
18
|
+
* 1. `<componentName>Data` — canonical pattern
|
|
19
|
+
* 2. `I<componentName>Data` — Hungarian variant
|
|
20
|
+
* 3. `<componentName>Props` — older code uses this for the data shape
|
|
21
|
+
*
|
|
22
|
+
* USAGE: pass the returned `declaration` to `getText()` for `propsCode`
|
|
23
|
+
* and `extractAjaxList()` for the `ajaxList` field.
|
|
24
|
+
*/
|
|
25
|
+
export declare const findComponentDataTypeForName: (ctx: SchemaContext, componentName: string) => {
|
|
26
|
+
typeName: string;
|
|
27
|
+
declaration: any;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Extract ajax-pathname field names directly declared on the props
|
|
31
|
+
* interface or type alias.
|
|
32
|
+
*
|
|
33
|
+
* ASSUMES: `declaration` is an `InterfaceDeclaration` or
|
|
34
|
+
* `TypeAliasDeclaration` (typically the one returned by
|
|
35
|
+
* `findComponentDataTypeForName`).
|
|
36
|
+
*
|
|
37
|
+
* RETURNS: sorted unique field names whose identifier starts with
|
|
38
|
+
* `pathname`. Includes `pathname` itself plus camelCase variants
|
|
39
|
+
* (`pathnameClick`, `pathnameDelete`, ...).
|
|
40
|
+
*
|
|
41
|
+
* EDGE CASE: NESTED property signatures are also walked via
|
|
42
|
+
* `ts.forEachChild`. Future improvement could restrict to direct
|
|
43
|
+
* children of the type body to avoid bleed-through from anonymous
|
|
44
|
+
* inline types (cf. Python side which already limits to direct fields).
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* Direct members of the props type that start with `pathname`.
|
|
48
|
+
*
|
|
49
|
+
* Restricted to DIRECT members of the type body — nested object types
|
|
50
|
+
* with their own `pathname*` keys are NOT included to avoid spurious
|
|
51
|
+
* ajax fields bleeding from inner shapes.
|
|
52
|
+
*
|
|
53
|
+
* For interface declarations: walks `members`.
|
|
54
|
+
* For type aliases of TypeLiteral: walks `members`.
|
|
55
|
+
* For type aliases of union/intersection/other: returns []. To declare
|
|
56
|
+
* ajax fields, the props type must have a literal object shape.
|
|
57
|
+
*/
|
|
58
|
+
export declare const extractAjaxList: (declaration: any) => string[];
|
|
59
|
+
//# sourceMappingURL=findDataType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findDataType.d.ts","sourceRoot":"","sources":["../../../src/code/introspection/findDataType.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAEH,KAAK,aAAa,EACrB,MAAM,iBAAiB,CAAA;AAExB;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,4BAA4B,GACrC,KAAK,aAAa,EAClB,eAAe,MAAM,KACtB;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,GAAG,CAAA;CAmBtC,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAAI,aAAa,GAAG,KAAG,MAAM,EAwBxD,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locate the type passed to `<PieCard stored={X} />` in JSX.
|
|
3
|
+
*
|
|
4
|
+
* Policy decision (per Policy C in the spec discussion): the TS side
|
|
5
|
+
* recognises an Input variant ONLY through the `stored` prop. No
|
|
6
|
+
* naming-convention fallback. If the card uses a hidden `<input>` element
|
|
7
|
+
* instead of `stored`, that's intentional and the metadata reports no
|
|
8
|
+
* input shape.
|
|
9
|
+
*/
|
|
10
|
+
import type { SchemaContext } from './schemaContext';
|
|
11
|
+
/**
|
|
12
|
+
* Walk JSX `<PieCard stored={X}/>` attributes and recover the type of `X`.
|
|
13
|
+
*
|
|
14
|
+
* ASSUMES:
|
|
15
|
+
* - `ctx` was built with files that include `<PieCard>` JSX usage.
|
|
16
|
+
* - `files` is the list of files to scan (typically the component's
|
|
17
|
+
* own source files).
|
|
18
|
+
*
|
|
19
|
+
* RETURNS:
|
|
20
|
+
* - `{ typeName, declaration }` of the type alias / interface that
|
|
21
|
+
* types the `stored` expression, on first hit.
|
|
22
|
+
* - `null` if no `<PieCard stored=…>` is found in any file, or if the
|
|
23
|
+
* stored expression has no resolvable named type.
|
|
24
|
+
*
|
|
25
|
+
* ALGORITHM:
|
|
26
|
+
* 1. For each JSX `<PieCard>` element, look at attribute `stored`.
|
|
27
|
+
* 2. If its initializer is `{expr}`, ask the checker for `expr`'s
|
|
28
|
+
* type, then for that type's alias symbol or value symbol.
|
|
29
|
+
* 3. Take the first declaration that's an Interface/TypeAlias.
|
|
30
|
+
*
|
|
31
|
+
* EDGE CASES:
|
|
32
|
+
* - `<PieCard stored={anonymousObject}/>` where the inline object has
|
|
33
|
+
* no named type → returns `null`. Use a named interface or
|
|
34
|
+
* `as InputXxx` for the metadata to pick it up.
|
|
35
|
+
* - PieCard imported as a different name (`import { PieCard as Foo }`)
|
|
36
|
+
* → not detected. The tag-name check is strict on `"PieCard"`.
|
|
37
|
+
*/
|
|
38
|
+
export declare const findStoredAttributeType: (ctx: SchemaContext, files: string[]) => {
|
|
39
|
+
typeName: string;
|
|
40
|
+
declaration: any;
|
|
41
|
+
} | null;
|
|
42
|
+
//# sourceMappingURL=findInputType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findInputType.d.ts","sourceRoot":"","sources":["../../../src/code/introspection/findInputType.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAKpD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,uBAAuB,GAChC,KAAK,aAAa,EAClB,OAAO,MAAM,EAAE,KAChB;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,GAAG,CAAA;CAAE,GAAG,IAgE3C,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Introspection algorithms for `pieui card dump-metadata` and `check-sync`.
|
|
3
|
+
*
|
|
4
|
+
* Each submodule documents its inputs, assumptions, output shape, and
|
|
5
|
+
* algorithmic approach via per-function JSDoc.
|
|
6
|
+
*
|
|
7
|
+
* Public surface:
|
|
8
|
+
*
|
|
9
|
+
* schemaContext:
|
|
10
|
+
* - createSchemaContext(files): SchemaContext
|
|
11
|
+
* - findTypeDeclaration(program, checker, name): { symbol, declaration } | null
|
|
12
|
+
* - buildSchemaForType(ctx, typeName): JSONSchema | null
|
|
13
|
+
*
|
|
14
|
+
* typeToSchema:
|
|
15
|
+
* - typeToSchema(tsType, checker): JSONSchema
|
|
16
|
+
*
|
|
17
|
+
* collectFiles:
|
|
18
|
+
* - collectComponentFiles(componentDir): string[]
|
|
19
|
+
*
|
|
20
|
+
* extractImports:
|
|
21
|
+
* - extractImports(files, cwd?): { relativeImports, packages }
|
|
22
|
+
*
|
|
23
|
+
* extractEvents:
|
|
24
|
+
* - extractEvents(files): string[] // strict: throws on non-literal
|
|
25
|
+
*
|
|
26
|
+
* extractEventsPayloads:
|
|
27
|
+
* - followIdentifierToFunction(ctx, ident): Parameter | null
|
|
28
|
+
* - schemaForParameter(ctx, param, sourceFile): { code, schema }
|
|
29
|
+
* - extractEventsPayloads(ctx, files, events): { code, schema }
|
|
30
|
+
*
|
|
31
|
+
* findDataType:
|
|
32
|
+
* - findComponentDataTypeForName(ctx, name): { typeName, declaration } | null
|
|
33
|
+
* - extractAjaxList(declaration): string[]
|
|
34
|
+
*
|
|
35
|
+
* findInputType:
|
|
36
|
+
* - findStoredAttributeType(ctx, files): { typeName, declaration } | null
|
|
37
|
+
*/
|
|
38
|
+
export { IntrospectionError } from './errors';
|
|
39
|
+
export { createSchemaContext, findTypeDeclaration, buildSchemaForType, type SchemaContext, } from './schemaContext';
|
|
40
|
+
export { typeToSchema } from './typeToSchema';
|
|
41
|
+
export { collectComponentFiles } from './collectFiles';
|
|
42
|
+
export { extractImports, type ImportSplit } from './extractImports';
|
|
43
|
+
export { extractEvents } from './extractEvents';
|
|
44
|
+
export { followIdentifierToFunction, schemaForParameter, extractEventsPayloads, } from './extractEventsPayloads';
|
|
45
|
+
export { findComponentDataTypeForName, extractAjaxList, } from './findDataType';
|
|
46
|
+
export { findStoredAttributeType } from './findInputType';
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/code/introspection/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EACH,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,aAAa,GACrB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EACH,0BAA0B,EAC1B,kBAAkB,EAClB,qBAAqB,GACxB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACH,4BAA4B,EAC5B,eAAe,GAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript compiler context for schema generation.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `typescript-json-schema`'s program/checker/generator triple so
|
|
5
|
+
* other introspection helpers can resolve named types into JSON Schemas
|
|
6
|
+
* without each carrying its own copy of the compiler setup.
|
|
7
|
+
*
|
|
8
|
+
* The CLI's `cli-schema.d.ts` is always injected as the first file so
|
|
9
|
+
* built-in helper types are visible to the generator.
|
|
10
|
+
*/
|
|
11
|
+
import type { JSONSchema } from '../types';
|
|
12
|
+
export type SchemaContext = {
|
|
13
|
+
program: any;
|
|
14
|
+
checker: any;
|
|
15
|
+
generator: any;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Build a `SchemaContext` from a list of source files.
|
|
19
|
+
*
|
|
20
|
+
* ASSUMES:
|
|
21
|
+
* - `files` are absolute paths (`.ts` or `.tsx`).
|
|
22
|
+
* - The TS compiler can read them with the default options below.
|
|
23
|
+
*
|
|
24
|
+
* RETURNS: an opaque context that callers pass to
|
|
25
|
+
* `findTypeDeclaration` and `buildSchemaForType`. The generator inside
|
|
26
|
+
* comes from `typescript-json-schema` and respects `strictNullChecks`,
|
|
27
|
+
* `noExtraProps: true`, and `ignoreErrors: true` (so partially-broken
|
|
28
|
+
* files still yield best-effort schemas).
|
|
29
|
+
*/
|
|
30
|
+
export declare const createSchemaContext: (files: string[]) => SchemaContext;
|
|
31
|
+
/**
|
|
32
|
+
* Find an interface or type-alias declaration by name across all
|
|
33
|
+
* source files in the program.
|
|
34
|
+
*
|
|
35
|
+
* ASSUMES: `program` was built by `createSchemaContext` (i.e. has the
|
|
36
|
+
* relevant files loaded).
|
|
37
|
+
*
|
|
38
|
+
* RETURNS: `{ symbol, declaration }` for the first matching
|
|
39
|
+
* InterfaceDeclaration or TypeAliasDeclaration; `null` if not found.
|
|
40
|
+
*
|
|
41
|
+
* ALGORITHM: linear walk over every non-`.d.ts` source file, DFS into
|
|
42
|
+
* the AST. Returns at first hit; declaration files are skipped because
|
|
43
|
+
* we want user-declared types only.
|
|
44
|
+
*/
|
|
45
|
+
export declare const findTypeDeclaration: (program: any, checker: any, typeName: string) => {
|
|
46
|
+
symbol: any;
|
|
47
|
+
declaration: any;
|
|
48
|
+
} | null;
|
|
49
|
+
/**
|
|
50
|
+
* Build a JSON Schema for a named TS type (interface or type alias).
|
|
51
|
+
*
|
|
52
|
+
* ASSUMES: `typeName` is the identifier name of a declared type
|
|
53
|
+
* reachable from any source file in the context.
|
|
54
|
+
*
|
|
55
|
+
* RETURNS:
|
|
56
|
+
* - the JSON Schema produced by `typescript-json-schema`, then
|
|
57
|
+
* post-processed by `patchSchemaForType` so that special types like
|
|
58
|
+
* `CSSProperties` collapse to `{ type: "object", additionalProperties: true }`.
|
|
59
|
+
* - `null` if the generator fails or the type isn't found.
|
|
60
|
+
*
|
|
61
|
+
* ALGORITHM:
|
|
62
|
+
* 1. `generator.getSchemaForSymbol(typeName)` produces the raw schema.
|
|
63
|
+
* 2. `findTypeDeclaration` locates the declaration node so the
|
|
64
|
+
* post-processor can walk it with the checker.
|
|
65
|
+
* 3. `patchSchemaForType` mutates the schema to fix known
|
|
66
|
+
* `typescript-json-schema` quirks (CSSProperties, etc.).
|
|
67
|
+
*/
|
|
68
|
+
export declare const buildSchemaForType: (ctx: SchemaContext, typeName: string) => JSONSchema | null;
|
|
69
|
+
//# sourceMappingURL=schemaContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaContext.d.ts","sourceRoot":"","sources":["../../../src/code/introspection/schemaContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,MAAM,MAAM,aAAa,GAAG;IACxB,OAAO,EAAE,GAAG,CAAA;IACZ,OAAO,EAAE,GAAG,CAAA;IACZ,SAAS,EAAE,GAAG,CAAA;CACjB,CAAA;AAaD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,EAAE,KAAG,aA2BrD,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,GAC5B,SAAS,GAAG,EACZ,SAAS,GAAG,EACZ,UAAU,MAAM,KACjB;IAAE,MAAM,EAAE,GAAG,CAAC;IAAC,WAAW,EAAE,GAAG,CAAA;CAAE,GAAG,IAuBtC,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,kBAAkB,GAC3B,KAAK,aAAa,EAClB,UAAU,MAAM,KACjB,UAAU,GAAG,IAiBf,CAAA"}
|