@atomic-ehr/codegen 0.0.1-canary.20251006092200.fdb4a88 → 0.0.1-canary.20251006094042.7f0be72
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/cli/index.js +45 -124
- package/dist/index.d.ts +2130 -62
- package/dist/index.js +5865 -84
- package/dist/index.js.map +1 -0
- package/package.json +3 -7
- package/dist/api/builder.d.ts +0 -154
- package/dist/api/builder.js +0 -341
- package/dist/api/generators/base/BaseGenerator.d.ts +0 -186
- package/dist/api/generators/base/BaseGenerator.js +0 -565
- package/dist/api/generators/base/FileManager.d.ts +0 -88
- package/dist/api/generators/base/FileManager.js +0 -202
- package/dist/api/generators/base/PythonTypeMapper.d.ts +0 -16
- package/dist/api/generators/base/PythonTypeMapper.js +0 -71
- package/dist/api/generators/base/TemplateEngine.d.ts +0 -126
- package/dist/api/generators/base/TemplateEngine.js +0 -133
- package/dist/api/generators/base/TypeMapper.d.ts +0 -129
- package/dist/api/generators/base/TypeMapper.js +0 -153
- package/dist/api/generators/base/TypeScriptTypeMapper.d.ts +0 -51
- package/dist/api/generators/base/TypeScriptTypeMapper.js +0 -232
- package/dist/api/generators/base/builders/DirectoryBuilder.d.ts +0 -99
- package/dist/api/generators/base/builders/DirectoryBuilder.js +0 -215
- package/dist/api/generators/base/builders/FileBuilder.d.ts +0 -160
- package/dist/api/generators/base/builders/FileBuilder.js +0 -406
- package/dist/api/generators/base/builders/IndexBuilder.d.ts +0 -126
- package/dist/api/generators/base/builders/IndexBuilder.js +0 -290
- package/dist/api/generators/base/enhanced-errors.d.ts +0 -84
- package/dist/api/generators/base/enhanced-errors.js +0 -259
- package/dist/api/generators/base/error-handler.d.ts +0 -89
- package/dist/api/generators/base/error-handler.js +0 -243
- package/dist/api/generators/base/errors.d.ts +0 -251
- package/dist/api/generators/base/errors.js +0 -692
- package/dist/api/generators/base/index.d.ts +0 -99
- package/dist/api/generators/base/index.js +0 -160
- package/dist/api/generators/base/types.d.ts +0 -433
- package/dist/api/generators/base/types.js +0 -12
- package/dist/api/generators/types.d.ts +0 -53
- package/dist/api/generators/types.js +0 -4
- package/dist/api/generators/typescript.d.ts +0 -190
- package/dist/api/generators/typescript.js +0 -819
- package/dist/api/index.d.ts +0 -51
- package/dist/api/index.js +0 -50
- package/dist/cli/commands/generate/typescript.d.ts +0 -10
- package/dist/cli/commands/generate/typescript.js +0 -52
- package/dist/cli/commands/generate.d.ts +0 -15
- package/dist/cli/commands/generate.js +0 -159
- package/dist/cli/commands/index.d.ts +0 -29
- package/dist/cli/commands/index.js +0 -100
- package/dist/cli/commands/typeschema/generate.d.ts +0 -19
- package/dist/cli/commands/typeschema/generate.js +0 -124
- package/dist/cli/commands/typeschema.d.ts +0 -10
- package/dist/cli/commands/typeschema.js +0 -47
- package/dist/cli/index.d.ts +0 -9
- package/dist/cli/utils/log.d.ts +0 -10
- package/dist/cli/utils/log.js +0 -23
- package/dist/cli/utils/prompts.d.ts +0 -56
- package/dist/cli/utils/prompts.js +0 -202
- package/dist/cli/utils/spinner.d.ts +0 -110
- package/dist/cli/utils/spinner.js +0 -266
- package/dist/config.d.ts +0 -217
- package/dist/config.js +0 -591
- package/dist/logger.d.ts +0 -157
- package/dist/logger.js +0 -281
- package/dist/typeschema/cache.d.ts +0 -80
- package/dist/typeschema/cache.js +0 -239
- package/dist/typeschema/core/binding.d.ts +0 -11
- package/dist/typeschema/core/binding.js +0 -143
- package/dist/typeschema/core/field-builder.d.ts +0 -12
- package/dist/typeschema/core/field-builder.js +0 -123
- package/dist/typeschema/core/identifier.d.ts +0 -13
- package/dist/typeschema/core/identifier.js +0 -94
- package/dist/typeschema/core/nested-types.d.ts +0 -9
- package/dist/typeschema/core/nested-types.js +0 -93
- package/dist/typeschema/core/transformer.d.ts +0 -11
- package/dist/typeschema/core/transformer.js +0 -235
- package/dist/typeschema/generator.d.ts +0 -36
- package/dist/typeschema/generator.js +0 -243
- package/dist/typeschema/index.d.ts +0 -15
- package/dist/typeschema/index.js +0 -15
- package/dist/typeschema/parser.d.ts +0 -79
- package/dist/typeschema/parser.js +0 -274
- package/dist/typeschema/profile/processor.d.ts +0 -14
- package/dist/typeschema/profile/processor.js +0 -261
- package/dist/typeschema/register.d.ts +0 -21
- package/dist/typeschema/register.js +0 -117
- package/dist/typeschema/types.d.ts +0 -240
- package/dist/typeschema/types.js +0 -19
- package/dist/utils/codegen-logger.d.ts +0 -102
- package/dist/utils/codegen-logger.js +0 -196
- package/dist/utils.d.ts +0 -22
- package/dist/utils.js +0 -42
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { CanonicalManager } from "@atomic-ehr/fhir-canonical-manager";
|
|
2
|
-
import * as fhirschema from "@atomic-ehr/fhirschema";
|
|
3
|
-
import { enrichFHIRSchema } from "@typeschema/types";
|
|
4
|
-
// FIXME: working with multiple packages
|
|
5
|
-
export const registerFromManager = async (manager, logger, packageInfo) => {
|
|
6
|
-
const resources = await manager.search({});
|
|
7
|
-
const any = {};
|
|
8
|
-
for (const resource of resources) {
|
|
9
|
-
const url = resource.url;
|
|
10
|
-
if (!url)
|
|
11
|
-
continue;
|
|
12
|
-
any[url] = resource;
|
|
13
|
-
}
|
|
14
|
-
const structureDefinitions = {};
|
|
15
|
-
for (const resource of resources) {
|
|
16
|
-
if (resource.resourceType === "StructureDefinition") {
|
|
17
|
-
const url = resource.url;
|
|
18
|
-
structureDefinitions[url] = resource;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
const fhirSchemas = {};
|
|
22
|
-
const nameDict = {};
|
|
23
|
-
let [success, failed] = [0, 0];
|
|
24
|
-
for (const sd of Object.values(structureDefinitions)) {
|
|
25
|
-
try {
|
|
26
|
-
const rfs = enrichFHIRSchema(fhirschema.translate(sd), packageInfo);
|
|
27
|
-
fhirSchemas[rfs.url] = rfs;
|
|
28
|
-
nameDict[rfs.name] = rfs.url;
|
|
29
|
-
success++;
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
logger?.warn(`Failed to convert StructureDefinition ${sd.name || sd.id}: ${error instanceof Error ? error.message : String(error)}`);
|
|
33
|
-
failed++;
|
|
34
|
-
}
|
|
35
|
-
logger?.success(`FHIR Schema conversion completed: ${success}/${Object.values(structureDefinitions).length} successful, ${failed} failed`);
|
|
36
|
-
}
|
|
37
|
-
const valueSets = {};
|
|
38
|
-
for (const resource of resources) {
|
|
39
|
-
if (resource.resourceType === "ValueSet") {
|
|
40
|
-
if (!resource.package_meta) {
|
|
41
|
-
resource.package_meta = packageInfo;
|
|
42
|
-
}
|
|
43
|
-
valueSets[resource.url] = resource;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const complexTypes = {};
|
|
47
|
-
for (const fs of Object.values(fhirSchemas)) {
|
|
48
|
-
if (fs.kind === "complex-type") {
|
|
49
|
-
complexTypes[fs.url] = fs;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const resolveFsGenealogy = (canonicalUrl) => {
|
|
53
|
-
let fs = fhirSchemas[canonicalUrl];
|
|
54
|
-
if (fs === undefined)
|
|
55
|
-
throw new Error(`Failed to resolve FHIR Schema genealogy for '${canonicalUrl}'`);
|
|
56
|
-
const genealogy = [fs];
|
|
57
|
-
while (fs?.base) {
|
|
58
|
-
fs = fhirSchemas[fs.base] || fhirSchemas[nameDict[fs.base]];
|
|
59
|
-
genealogy.push(fs);
|
|
60
|
-
if (fs === undefined)
|
|
61
|
-
throw new Error(`Failed to resolve FHIR Schema genealogy for '${canonicalUrl}'`);
|
|
62
|
-
}
|
|
63
|
-
return genealogy;
|
|
64
|
-
};
|
|
65
|
-
return {
|
|
66
|
-
...manager,
|
|
67
|
-
appendFs(fs) {
|
|
68
|
-
const rfs = enrichFHIRSchema(fs);
|
|
69
|
-
fhirSchemas[rfs.url] = rfs;
|
|
70
|
-
nameDict[rfs.name] = rfs.url;
|
|
71
|
-
},
|
|
72
|
-
resolveFs: (canonicalUrl) => fhirSchemas[canonicalUrl],
|
|
73
|
-
resolveFsGenealogy: resolveFsGenealogy,
|
|
74
|
-
ensureCanonicalUrl: (name) => nameDict[name] || name,
|
|
75
|
-
allSd: () => Object.values(structureDefinitions),
|
|
76
|
-
resolveSd: (canonicalUrl) => structureDefinitions[canonicalUrl],
|
|
77
|
-
allFs: () => Object.values(fhirSchemas),
|
|
78
|
-
allVs: () => Object.values(valueSets),
|
|
79
|
-
resolveVs: (canonicalUrl) => valueSets[canonicalUrl],
|
|
80
|
-
complexTypeDict: () => complexTypes,
|
|
81
|
-
resolveAny: (canonicalUrl) => any[canonicalUrl],
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
export const registerFromPackageMetas = async (packageMetas, logger) => {
|
|
85
|
-
const packageNames = packageMetas.map((meta) => `${meta.name}@${meta.version}`);
|
|
86
|
-
logger?.step(`Loading FHIR packages: ${packageNames.join(", ")}`);
|
|
87
|
-
const manager = CanonicalManager({
|
|
88
|
-
packages: packageNames,
|
|
89
|
-
workingDir: "tmp/fhir",
|
|
90
|
-
});
|
|
91
|
-
await manager.init();
|
|
92
|
-
// Pass package info from the first package (assuming single package for now)
|
|
93
|
-
return await registerFromManager(manager, logger, packageMetas[0]);
|
|
94
|
-
};
|
|
95
|
-
export const resolveFsElementGenealogy = (genealogy, path) => {
|
|
96
|
-
const [top, ...rest] = path;
|
|
97
|
-
if (top === undefined)
|
|
98
|
-
return [];
|
|
99
|
-
return genealogy
|
|
100
|
-
.map((fs) => {
|
|
101
|
-
if (!fs.elements)
|
|
102
|
-
return undefined;
|
|
103
|
-
let elem = fs.elements?.[top];
|
|
104
|
-
for (const k of rest) {
|
|
105
|
-
elem = elem?.elements?.[k];
|
|
106
|
-
}
|
|
107
|
-
return elem;
|
|
108
|
-
})
|
|
109
|
-
.filter((elem) => elem !== undefined);
|
|
110
|
-
};
|
|
111
|
-
export function fsElementSnapshot(genealogy) {
|
|
112
|
-
// FIXME: nested elements will break it
|
|
113
|
-
const snapshot = genealogy.reverse().reduce((snapshot, elem) => ({ ...snapshot, ...elem }), {});
|
|
114
|
-
// NOTE: to avoid regeneration nested types
|
|
115
|
-
snapshot.elements = undefined;
|
|
116
|
-
return snapshot;
|
|
117
|
-
}
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A code generation friendly representation of FHIR StructureDefinition and
|
|
3
|
-
* FHIR Schema designed to simplify SDK resource classes/types generation.
|
|
4
|
-
*/
|
|
5
|
-
import type { CanonicalManager } from "@atomic-ehr/fhir-canonical-manager";
|
|
6
|
-
import type * as FS from "@atomic-ehr/fhirschema";
|
|
7
|
-
export type Name = string & {
|
|
8
|
-
readonly __brand: unique symbol;
|
|
9
|
-
};
|
|
10
|
-
export type CanonicalUrl = string & {
|
|
11
|
-
readonly __brand: unique symbol;
|
|
12
|
-
};
|
|
13
|
-
export interface PackageMeta {
|
|
14
|
-
name: string;
|
|
15
|
-
version: string;
|
|
16
|
-
}
|
|
17
|
-
export type RichFHIRSchema = Omit<FS.FHIRSchema, "package_meta" | "base" | "name" | "url"> & {
|
|
18
|
-
package_meta: PackageMeta;
|
|
19
|
-
name: Name;
|
|
20
|
-
url: CanonicalUrl;
|
|
21
|
-
base: CanonicalUrl;
|
|
22
|
-
};
|
|
23
|
-
export declare const enrichFHIRSchema: (schema: FS.FHIRSchema, packageMeta?: PackageMeta) => RichFHIRSchema;
|
|
24
|
-
type IdentifierBase = {
|
|
25
|
-
name: Name;
|
|
26
|
-
url: CanonicalUrl;
|
|
27
|
-
package: string;
|
|
28
|
-
version: string;
|
|
29
|
-
};
|
|
30
|
-
type PrimitiveIdentifier = {
|
|
31
|
-
kind: "primitive-type";
|
|
32
|
-
} & IdentifierBase;
|
|
33
|
-
type ComplexTypeIdentifier = {
|
|
34
|
-
kind: "complex-type";
|
|
35
|
-
} & IdentifierBase;
|
|
36
|
-
type ResourceIdentifier = {
|
|
37
|
-
kind: "resource";
|
|
38
|
-
} & IdentifierBase;
|
|
39
|
-
export type ValueSetIdentifier = {
|
|
40
|
-
kind: "value-set";
|
|
41
|
-
} & IdentifierBase;
|
|
42
|
-
export type NestedIdentifier = {
|
|
43
|
-
kind: "nested";
|
|
44
|
-
} & IdentifierBase;
|
|
45
|
-
export type BindingIdentifier = {
|
|
46
|
-
kind: "binding";
|
|
47
|
-
} & IdentifierBase;
|
|
48
|
-
type ProfileIdentifier = {
|
|
49
|
-
kind: "profile";
|
|
50
|
-
} & IdentifierBase;
|
|
51
|
-
type LogicalIdentifier = {
|
|
52
|
-
kind: "logical";
|
|
53
|
-
} & IdentifierBase;
|
|
54
|
-
export type Identifier = PrimitiveIdentifier | ComplexTypeIdentifier | ResourceIdentifier | NestedIdentifier | BindingIdentifier | ValueSetIdentifier | ProfileIdentifier | LogicalIdentifier;
|
|
55
|
-
export type TypeSchema = RegularTypeSchema | PrimitiveTypeSchema | ValueSetTypeSchema | BindingTypeSchema | ProfileTypeSchema;
|
|
56
|
-
interface PrimitiveTypeSchema {
|
|
57
|
-
identifier: PrimitiveIdentifier;
|
|
58
|
-
description?: string;
|
|
59
|
-
base: Identifier;
|
|
60
|
-
dependencies?: Identifier[];
|
|
61
|
-
}
|
|
62
|
-
export interface NestedType {
|
|
63
|
-
identifier: NestedIdentifier;
|
|
64
|
-
base: Identifier;
|
|
65
|
-
fields: Record<string, Field>;
|
|
66
|
-
}
|
|
67
|
-
export interface ProfileTypeSchema {
|
|
68
|
-
identifier: ProfileIdentifier;
|
|
69
|
-
base: Identifier;
|
|
70
|
-
description?: string;
|
|
71
|
-
fields?: Record<string, Field>;
|
|
72
|
-
constraints?: Record<string, ProfileConstraint>;
|
|
73
|
-
extensions?: ProfileExtension[];
|
|
74
|
-
validation?: ValidationRule[];
|
|
75
|
-
dependencies?: Identifier[];
|
|
76
|
-
metadata?: ProfileMetadata;
|
|
77
|
-
nested?: NestedType[];
|
|
78
|
-
}
|
|
79
|
-
export interface ProfileConstraint {
|
|
80
|
-
min?: number;
|
|
81
|
-
max?: string;
|
|
82
|
-
mustSupport?: boolean;
|
|
83
|
-
fixedValue?: any;
|
|
84
|
-
patternValue?: any;
|
|
85
|
-
binding?: {
|
|
86
|
-
strength: "required" | "extensible" | "preferred" | "example";
|
|
87
|
-
valueSet: string;
|
|
88
|
-
};
|
|
89
|
-
types?: Array<{
|
|
90
|
-
code: string;
|
|
91
|
-
profile?: string[];
|
|
92
|
-
targetProfile?: string[];
|
|
93
|
-
}>;
|
|
94
|
-
slicing?: {
|
|
95
|
-
discriminator: any[];
|
|
96
|
-
rules: string;
|
|
97
|
-
ordered?: boolean;
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
export interface ProfileExtension {
|
|
101
|
-
path: string;
|
|
102
|
-
profile: string | string[];
|
|
103
|
-
min?: number;
|
|
104
|
-
max?: string;
|
|
105
|
-
mustSupport?: boolean;
|
|
106
|
-
}
|
|
107
|
-
export interface ValidationRule {
|
|
108
|
-
path: string;
|
|
109
|
-
key: string;
|
|
110
|
-
severity: "error" | "warning" | "information";
|
|
111
|
-
human: string;
|
|
112
|
-
expression?: string;
|
|
113
|
-
}
|
|
114
|
-
export interface ProfileMetadata {
|
|
115
|
-
publisher?: string;
|
|
116
|
-
contact?: any[];
|
|
117
|
-
copyright?: string;
|
|
118
|
-
purpose?: string;
|
|
119
|
-
experimental?: boolean;
|
|
120
|
-
date?: string;
|
|
121
|
-
jurisdiction?: any[];
|
|
122
|
-
package?: string;
|
|
123
|
-
}
|
|
124
|
-
interface RegularTypeSchema {
|
|
125
|
-
identifier: Identifier;
|
|
126
|
-
base?: Identifier;
|
|
127
|
-
description?: string;
|
|
128
|
-
fields?: {
|
|
129
|
-
[k: string]: Field;
|
|
130
|
-
};
|
|
131
|
-
nested?: NestedType[];
|
|
132
|
-
dependencies?: Identifier[];
|
|
133
|
-
}
|
|
134
|
-
export interface RegularField {
|
|
135
|
-
type: Identifier;
|
|
136
|
-
reference?: Identifier[];
|
|
137
|
-
required?: boolean;
|
|
138
|
-
excluded?: boolean;
|
|
139
|
-
array?: boolean;
|
|
140
|
-
binding?: BindingIdentifier;
|
|
141
|
-
enum?: string[];
|
|
142
|
-
min?: number;
|
|
143
|
-
max?: number;
|
|
144
|
-
}
|
|
145
|
-
export interface ChoiceFieldDeclaration {
|
|
146
|
-
choices: string[];
|
|
147
|
-
required?: boolean;
|
|
148
|
-
excluded?: boolean;
|
|
149
|
-
array?: boolean;
|
|
150
|
-
min?: number;
|
|
151
|
-
max?: number;
|
|
152
|
-
}
|
|
153
|
-
interface ChoiceFieldInstance {
|
|
154
|
-
choiceOf: string;
|
|
155
|
-
type: Identifier;
|
|
156
|
-
required?: boolean;
|
|
157
|
-
excluded?: boolean;
|
|
158
|
-
array?: boolean;
|
|
159
|
-
reference?: Identifier[];
|
|
160
|
-
binding?: BindingIdentifier;
|
|
161
|
-
enum?: string[];
|
|
162
|
-
min?: number;
|
|
163
|
-
max?: number;
|
|
164
|
-
}
|
|
165
|
-
export type Concept = {
|
|
166
|
-
code: string;
|
|
167
|
-
display?: string;
|
|
168
|
-
system?: string;
|
|
169
|
-
};
|
|
170
|
-
export interface ValueSetTypeSchema {
|
|
171
|
-
identifier: ValueSetIdentifier;
|
|
172
|
-
description?: string;
|
|
173
|
-
concept?: Concept[];
|
|
174
|
-
compose?: ValueSetCompose;
|
|
175
|
-
}
|
|
176
|
-
export interface BindingTypeSchema {
|
|
177
|
-
identifier: BindingIdentifier;
|
|
178
|
-
description?: string;
|
|
179
|
-
type?: Identifier;
|
|
180
|
-
strength?: string;
|
|
181
|
-
enum?: string[];
|
|
182
|
-
valueset?: ValueSetIdentifier;
|
|
183
|
-
dependencies?: Identifier[];
|
|
184
|
-
}
|
|
185
|
-
export type Field = RegularField | ChoiceFieldDeclaration | ChoiceFieldInstance;
|
|
186
|
-
export interface TypeschemaGeneratorOptions {
|
|
187
|
-
verbose?: boolean;
|
|
188
|
-
logger?: import("../utils/codegen-logger").CodegenLogger;
|
|
189
|
-
treeshake?: string[];
|
|
190
|
-
manager?: ReturnType<typeof CanonicalManager> | null;
|
|
191
|
-
}
|
|
192
|
-
export declare function isBindingSchema(schema: TypeSchema): schema is BindingTypeSchema;
|
|
193
|
-
export type TypeschemaParserOptions = {
|
|
194
|
-
format?: "auto" | "ndjson" | "json";
|
|
195
|
-
validate?: boolean;
|
|
196
|
-
strict?: boolean;
|
|
197
|
-
};
|
|
198
|
-
export type ValueSet = {
|
|
199
|
-
resourceType: "ValueSet";
|
|
200
|
-
id: string;
|
|
201
|
-
name?: string;
|
|
202
|
-
url?: string;
|
|
203
|
-
description?: string;
|
|
204
|
-
compose?: ValueSetCompose;
|
|
205
|
-
expansion?: {
|
|
206
|
-
contains: Concept[];
|
|
207
|
-
};
|
|
208
|
-
experimental?: boolean;
|
|
209
|
-
immutable?: boolean;
|
|
210
|
-
extension?: any[];
|
|
211
|
-
status?: string;
|
|
212
|
-
identifier?: any[];
|
|
213
|
-
title?: string;
|
|
214
|
-
publisher?: string;
|
|
215
|
-
version?: string;
|
|
216
|
-
meta?: any;
|
|
217
|
-
date?: string;
|
|
218
|
-
contact?: any;
|
|
219
|
-
};
|
|
220
|
-
type ValueSetCompose = {
|
|
221
|
-
include: {
|
|
222
|
-
concept?: Concept[];
|
|
223
|
-
system?: string;
|
|
224
|
-
filter?: {}[];
|
|
225
|
-
}[];
|
|
226
|
-
};
|
|
227
|
-
export type CodeSystem = {
|
|
228
|
-
concept: CodeSystemConcept[];
|
|
229
|
-
};
|
|
230
|
-
export type CodeSystemConcept = {
|
|
231
|
-
concept: CodeSystemConcept[];
|
|
232
|
-
code: string;
|
|
233
|
-
display: string;
|
|
234
|
-
};
|
|
235
|
-
export type RichValueSet = Omit<ValueSet, "name" | "url"> & {
|
|
236
|
-
package_meta: PackageMeta;
|
|
237
|
-
name?: Name;
|
|
238
|
-
url?: CanonicalUrl;
|
|
239
|
-
};
|
|
240
|
-
export {};
|
package/dist/typeschema/types.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A code generation friendly representation of FHIR StructureDefinition and
|
|
3
|
-
* FHIR Schema designed to simplify SDK resource classes/types generation.
|
|
4
|
-
*/
|
|
5
|
-
export const enrichFHIRSchema = (schema, packageMeta) => {
|
|
6
|
-
if (!packageMeta) {
|
|
7
|
-
packageMeta = { name: "undefined", version: "undefined" };
|
|
8
|
-
}
|
|
9
|
-
return {
|
|
10
|
-
...schema,
|
|
11
|
-
package_meta: schema.package_meta || packageMeta,
|
|
12
|
-
name: schema.name,
|
|
13
|
-
url: schema.url,
|
|
14
|
-
base: schema.base,
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export function isBindingSchema(schema) {
|
|
18
|
-
return schema.identifier.kind === "binding";
|
|
19
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CodeGen Logger
|
|
3
|
-
*
|
|
4
|
-
* Clean, colorful logging designed for code generation tools
|
|
5
|
-
*/
|
|
6
|
-
export interface LogOptions {
|
|
7
|
-
prefix?: string;
|
|
8
|
-
timestamp?: boolean;
|
|
9
|
-
verbose?: boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Simple code generation logger with pretty colors and clean formatting
|
|
13
|
-
*/
|
|
14
|
-
export declare class CodegenLogger {
|
|
15
|
-
private options;
|
|
16
|
-
constructor(options?: LogOptions);
|
|
17
|
-
private formatMessage;
|
|
18
|
-
/**
|
|
19
|
-
* Success message with checkmark
|
|
20
|
-
*/
|
|
21
|
-
success(message: string): void;
|
|
22
|
-
/**
|
|
23
|
-
* Error message with X mark
|
|
24
|
-
*/
|
|
25
|
-
error(message: string, error?: Error): void;
|
|
26
|
-
/**
|
|
27
|
-
* Warning message with warning sign
|
|
28
|
-
*/
|
|
29
|
-
warn(message: string): void;
|
|
30
|
-
/**
|
|
31
|
-
* Info message with info icon
|
|
32
|
-
*/
|
|
33
|
-
info(message: string): void;
|
|
34
|
-
/**
|
|
35
|
-
* Debug message (only shows in verbose mode)
|
|
36
|
-
*/
|
|
37
|
-
debug(message: string): void;
|
|
38
|
-
/**
|
|
39
|
-
* Step message with rocket
|
|
40
|
-
*/
|
|
41
|
-
step(message: string): void;
|
|
42
|
-
/**
|
|
43
|
-
* Progress message with clock
|
|
44
|
-
*/
|
|
45
|
-
progress(message: string): void;
|
|
46
|
-
/**
|
|
47
|
-
* Plain message (no icon, just colored text)
|
|
48
|
-
*/
|
|
49
|
-
plain(message: string, color?: (str: string) => string): void;
|
|
50
|
-
/**
|
|
51
|
-
* Dimmed/gray text for less important info
|
|
52
|
-
*/
|
|
53
|
-
dim(message: string): void;
|
|
54
|
-
/**
|
|
55
|
-
* Create a child logger with a prefix
|
|
56
|
-
*/
|
|
57
|
-
child(prefix: string): CodegenLogger;
|
|
58
|
-
/**
|
|
59
|
-
* Update options
|
|
60
|
-
*/
|
|
61
|
-
configure(options: Partial<LogOptions>): void;
|
|
62
|
-
}
|
|
63
|
-
export declare function success(message: string): void;
|
|
64
|
-
export declare function error(message: string, err?: Error): void;
|
|
65
|
-
export declare function warn(message: string): void;
|
|
66
|
-
export declare function info(message: string): void;
|
|
67
|
-
export declare function debug(message: string): void;
|
|
68
|
-
export declare function step(message: string): void;
|
|
69
|
-
export declare function progress(message: string): void;
|
|
70
|
-
export declare function plain(message: string, color?: (str: string) => string): void;
|
|
71
|
-
export declare function dim(message: string): void;
|
|
72
|
-
/**
|
|
73
|
-
* Configure the default logger
|
|
74
|
-
*/
|
|
75
|
-
export declare function configure(options: Partial<LogOptions>): void;
|
|
76
|
-
/**
|
|
77
|
-
* Create a new logger instance
|
|
78
|
-
*/
|
|
79
|
-
export declare function createLogger(options?: LogOptions): CodegenLogger;
|
|
80
|
-
/**
|
|
81
|
-
* Convenience functions for common CLI patterns
|
|
82
|
-
*/
|
|
83
|
-
/**
|
|
84
|
-
* Show a command header with separator
|
|
85
|
-
*/
|
|
86
|
-
export declare function header(title: string): void;
|
|
87
|
-
/**
|
|
88
|
-
* Show a section break
|
|
89
|
-
*/
|
|
90
|
-
export declare function section(title: string): void;
|
|
91
|
-
/**
|
|
92
|
-
* Show completion message with stats
|
|
93
|
-
*/
|
|
94
|
-
export declare function complete(message: string, duration?: number, stats?: Record<string, number>): void;
|
|
95
|
-
/**
|
|
96
|
-
* Show a list of items
|
|
97
|
-
*/
|
|
98
|
-
export declare function list(items: string[], bullet?: string): void;
|
|
99
|
-
/**
|
|
100
|
-
* Show key-value pairs
|
|
101
|
-
*/
|
|
102
|
-
export declare function table(data: Record<string, string | number>): void;
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CodeGen Logger
|
|
3
|
-
*
|
|
4
|
-
* Clean, colorful logging designed for code generation tools
|
|
5
|
-
*/
|
|
6
|
-
import pc from "picocolors";
|
|
7
|
-
/**
|
|
8
|
-
* Simple code generation logger with pretty colors and clean formatting
|
|
9
|
-
*/
|
|
10
|
-
export class CodegenLogger {
|
|
11
|
-
options;
|
|
12
|
-
constructor(options = {}) {
|
|
13
|
-
this.options = {
|
|
14
|
-
timestamp: false,
|
|
15
|
-
verbose: false,
|
|
16
|
-
...options,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
formatMessage(level, message, color) {
|
|
20
|
-
const timestamp = this.options.timestamp ? `${pc.gray(new Date().toLocaleTimeString())} ` : "";
|
|
21
|
-
const prefix = this.options.prefix ? `${pc.cyan(`[${this.options.prefix}]`)} ` : "";
|
|
22
|
-
return `${timestamp}${color(level)} ${prefix}${message}`;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Success message with checkmark
|
|
26
|
-
*/
|
|
27
|
-
success(message) {
|
|
28
|
-
console.log(this.formatMessage("✅", message, pc.green));
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Error message with X mark
|
|
32
|
-
*/
|
|
33
|
-
error(message, error) {
|
|
34
|
-
console.error(this.formatMessage("❌", message, pc.red));
|
|
35
|
-
if (error && this.options.verbose) {
|
|
36
|
-
console.error(pc.red(` ${error.message}`));
|
|
37
|
-
if (error.stack) {
|
|
38
|
-
console.error(pc.gray(error.stack));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Warning message with warning sign
|
|
44
|
-
*/
|
|
45
|
-
warn(message) {
|
|
46
|
-
console.warn(this.formatMessage("⚠️", message, pc.yellow));
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Info message with info icon
|
|
50
|
-
*/
|
|
51
|
-
info(message) {
|
|
52
|
-
console.log(this.formatMessage("ℹ️", message, pc.blue));
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Debug message (only shows in verbose mode)
|
|
56
|
-
*/
|
|
57
|
-
debug(message) {
|
|
58
|
-
if (this.options.verbose) {
|
|
59
|
-
console.log(this.formatMessage("🐛", message, pc.magenta));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Step message with rocket
|
|
64
|
-
*/
|
|
65
|
-
step(message) {
|
|
66
|
-
console.log(this.formatMessage("🚀", message, pc.cyan));
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Progress message with clock
|
|
70
|
-
*/
|
|
71
|
-
progress(message) {
|
|
72
|
-
console.log(this.formatMessage("⏳", message, pc.blue));
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Plain message (no icon, just colored text)
|
|
76
|
-
*/
|
|
77
|
-
plain(message, color = (s) => s) {
|
|
78
|
-
const timestamp = this.options.timestamp ? `${pc.gray(new Date().toLocaleTimeString())} ` : "";
|
|
79
|
-
const prefix = this.options.prefix ? `${pc.cyan(`[${this.options.prefix}]`)} ` : "";
|
|
80
|
-
console.log(`${timestamp}${prefix}${color(message)}`);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Dimmed/gray text for less important info
|
|
84
|
-
*/
|
|
85
|
-
dim(message) {
|
|
86
|
-
this.plain(message, pc.gray);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Create a child logger with a prefix
|
|
90
|
-
*/
|
|
91
|
-
child(prefix) {
|
|
92
|
-
return new CodegenLogger({
|
|
93
|
-
...this.options,
|
|
94
|
-
prefix: this.options.prefix ? `${this.options.prefix}:${prefix}` : prefix,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Update options
|
|
99
|
-
*/
|
|
100
|
-
configure(options) {
|
|
101
|
-
this.options = { ...this.options, ...options };
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Quick logging functions for simple usage
|
|
106
|
-
*/
|
|
107
|
-
const defaultLogger = new CodegenLogger();
|
|
108
|
-
export function success(message) {
|
|
109
|
-
defaultLogger.success(message);
|
|
110
|
-
}
|
|
111
|
-
export function error(message, err) {
|
|
112
|
-
defaultLogger.error(message, err);
|
|
113
|
-
}
|
|
114
|
-
export function warn(message) {
|
|
115
|
-
defaultLogger.warn(message);
|
|
116
|
-
}
|
|
117
|
-
export function info(message) {
|
|
118
|
-
defaultLogger.info(message);
|
|
119
|
-
}
|
|
120
|
-
export function debug(message) {
|
|
121
|
-
defaultLogger.debug(message);
|
|
122
|
-
}
|
|
123
|
-
export function step(message) {
|
|
124
|
-
defaultLogger.step(message);
|
|
125
|
-
}
|
|
126
|
-
export function progress(message) {
|
|
127
|
-
defaultLogger.progress(message);
|
|
128
|
-
}
|
|
129
|
-
export function plain(message, color) {
|
|
130
|
-
defaultLogger.plain(message, color);
|
|
131
|
-
}
|
|
132
|
-
export function dim(message) {
|
|
133
|
-
defaultLogger.dim(message);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Configure the default logger
|
|
137
|
-
*/
|
|
138
|
-
export function configure(options) {
|
|
139
|
-
defaultLogger.configure(options);
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Create a new logger instance
|
|
143
|
-
*/
|
|
144
|
-
export function createLogger(options = {}) {
|
|
145
|
-
return new CodegenLogger(options);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Convenience functions for common CLI patterns
|
|
149
|
-
*/
|
|
150
|
-
/**
|
|
151
|
-
* Show a command header with separator
|
|
152
|
-
*/
|
|
153
|
-
export function header(title) {
|
|
154
|
-
console.log();
|
|
155
|
-
console.log(pc.cyan(pc.bold(`━━━ ${title} ━━━`)));
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Show a section break
|
|
159
|
-
*/
|
|
160
|
-
export function section(title) {
|
|
161
|
-
console.log();
|
|
162
|
-
console.log(pc.bold(title));
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Show completion message with stats
|
|
166
|
-
*/
|
|
167
|
-
export function complete(message, duration, stats) {
|
|
168
|
-
let msg = message;
|
|
169
|
-
if (duration) {
|
|
170
|
-
msg += ` ${pc.gray(`(${duration}ms)`)}`;
|
|
171
|
-
}
|
|
172
|
-
success(msg);
|
|
173
|
-
if (stats) {
|
|
174
|
-
Object.entries(stats).forEach(([key, value]) => {
|
|
175
|
-
dim(` ${key}: ${value}`);
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Show a list of items
|
|
181
|
-
*/
|
|
182
|
-
export function list(items, bullet = "•") {
|
|
183
|
-
items.forEach((item) => {
|
|
184
|
-
console.log(pc.gray(` ${bullet} ${item}`));
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Show key-value pairs
|
|
189
|
-
*/
|
|
190
|
-
export function table(data) {
|
|
191
|
-
const maxKeyLength = Math.max(...Object.keys(data).map((k) => k.length));
|
|
192
|
-
Object.entries(data).forEach(([key, value]) => {
|
|
193
|
-
const paddedKey = key.padEnd(maxKeyLength);
|
|
194
|
-
console.log(` ${pc.blue(paddedKey)} ${pc.gray("─")} ${value}`);
|
|
195
|
-
});
|
|
196
|
-
}
|
package/dist/utils.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert a string into PascalCase.
|
|
3
|
-
* Examples:
|
|
4
|
-
* - "patient-name" -> "PatientName"
|
|
5
|
-
* - "Patient name" -> "PatientName"
|
|
6
|
-
* - "patient_name" -> "PatientName"
|
|
7
|
-
* - "patientName" -> "PatientName"
|
|
8
|
-
*/
|
|
9
|
-
export declare function toPascalCase(input: string): string;
|
|
10
|
-
/**
|
|
11
|
-
* Split an array into chunks of a given size.
|
|
12
|
-
*
|
|
13
|
-
* Examples:
|
|
14
|
-
* - chunkArray([1,2,3,4,5], 2) -> [[1,2],[3,4],[5]]
|
|
15
|
-
* - chunkArray([], 3) -> []
|
|
16
|
-
*
|
|
17
|
-
* @param arr - The array to split.
|
|
18
|
-
* @param size - The maximum size of each chunk (must be >= 1).
|
|
19
|
-
* @returns An array of chunks (each chunk is an array of T).
|
|
20
|
-
* @throws RangeError if size is less than 1.
|
|
21
|
-
*/
|
|
22
|
-
export declare function chunkArray<T>(arr: T[], size: number): T[][];
|