crankscript 0.9.7 → 0.9.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crankscript",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "scripts": {
5
5
  "dev": "tsx src/index.ts",
6
6
  "post-build": "tsc-alias --project tsconfig.json",
@@ -23,7 +23,7 @@ export const useGenerateTypeFile = (path, definitions, typeProvider)=>{
23
23
  });
24
24
  const globalNamespace = definitions.global;
25
25
  typeFile.addStatements(typeProvider.getGlobalStatements());
26
- generateNamespace(globalNamespace, typeFile, typeProvider);
26
+ generateNamespace(globalNamespace, typeFile, typeProvider, '');
27
27
  writeFileSync(path, typeFile.getFullText().replace('/**', '\n/**'));
28
28
  },
29
29
  ready: definitions !== null && typeProvider !== null
@@ -36,8 +36,12 @@ export const useGenerateTypeFile = (path, definitions, typeProvider)=>{
36
36
  generateTypeFile
37
37
  };
38
38
  };
39
- const generateNamespace = (apiObject, incomingSubject, typeProvider, name)=>{
39
+ const generateNamespace = (apiObject, incomingSubject, typeProvider, namespace, name)=>{
40
40
  let subject = incomingSubject;
41
+ const fullNamespaceName = [
42
+ namespace,
43
+ name
44
+ ].filter(Boolean).join('.');
41
45
  if (name) {
42
46
  subject = incomingSubject.addModule({
43
47
  name
@@ -56,7 +60,8 @@ const generateNamespace = (apiObject, incomingSubject, typeProvider, name)=>{
56
60
  func.docs
57
61
  ],
58
62
  parameters,
59
- returnType: typeProvider.getFunctionReturnType(func)
63
+ returnType: typeProvider.getFunctionReturnType(func),
64
+ isExported: !!name
60
65
  }, typeProvider.getFunctionOverrideOptions(func)));
61
66
  if (isFunctionNameReserved) {
62
67
  subject.addExportDeclaration({
@@ -71,9 +76,9 @@ const generateNamespace = (apiObject, incomingSubject, typeProvider, name)=>{
71
76
  }
72
77
  let propertiesSubject = null;
73
78
  if (name && apiObject.methods.length > 0) {
74
- const typeClass = incomingSubject.addClass({
79
+ const typeClass = incomingSubject.addClass(_extends({
75
80
  name
76
- });
81
+ }, typeProvider.getClassOptions(fullNamespaceName)));
77
82
  propertiesSubject = typeClass;
78
83
  for (const method of apiObject.methods){
79
84
  const parameters = typeProvider.getParameters(method);
@@ -113,8 +118,8 @@ const generateNamespace = (apiObject, incomingSubject, typeProvider, name)=>{
113
118
  });
114
119
  }
115
120
  }
116
- for (const namespace of Object.entries(apiObject.namespaces)){
117
- generateNamespace(namespace[1], subject, typeProvider, namespace[0]);
121
+ for (const eachNamespace of Object.entries(apiObject.namespaces)){
122
+ generateNamespace(eachNamespace[1], subject, typeProvider, fullNamespaceName, eachNamespace[0]);
118
123
  }
119
124
  };
120
125
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGenerateTypeFile.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport { useMemo } from 'react';\nimport {\n ClassDeclaration,\n FunctionDeclarationStructure,\n MethodDeclarationStructure,\n ModuleDeclaration,\n Project,\n SourceFile,\n} from 'ts-morph';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport { TypescriptReservedNamed } from '@/cli/constants.js';\nimport { ApiDefinitions, ApiObject, CheckListItem } from '@/cli/types.js';\n\nexport const useGenerateTypeFile = (\n path: string,\n definitions: ApiDefinitions | null,\n typeProvider: ReturnType<typeof createTypeProvider> | null\n) => {\n const generateTypeFile = useMemo(() => {\n return {\n waitingDescription: 'Waiting to generate the type file...',\n errorDescription: 'Failed to generate the type file',\n finishedDescription: () => 'Type file generated',\n runningDescription: 'Generating the type file...',\n runner: async () => {\n if (!definitions) {\n throw new Error('Definitions are not set');\n }\n\n if (!typeProvider) {\n throw new Error('Type provider is not set');\n }\n\n const project = new Project();\n const typeFile = project.createSourceFile(path, '', {\n overwrite: true,\n });\n\n const globalNamespace = definitions.global;\n\n typeFile.addStatements(typeProvider.getGlobalStatements());\n\n generateNamespace(globalNamespace, typeFile, typeProvider);\n\n writeFileSync(\n path,\n typeFile.getFullText().replace('/**', '\\n/**')\n );\n },\n ready: definitions !== null && typeProvider !== null,\n } satisfies CheckListItem<void>;\n }, [definitions, typeProvider]);\n\n return {\n generateTypeFile,\n };\n};\n\nconst generateNamespace = (\n apiObject: ApiObject,\n incomingSubject: SourceFile | ModuleDeclaration,\n typeProvider: ReturnType<typeof createTypeProvider>,\n name?: string\n) => {\n let subject = incomingSubject;\n\n if (name) {\n subject = incomingSubject.addModule({\n name,\n });\n }\n\n if (name === 'playdate') {\n subject.addStatements(typeProvider.getStatements());\n }\n\n for (const func of apiObject.functions) {\n const isFunctionNameReserved = TypescriptReservedNamed.includes(\n func.name\n );\n const resolvedName = `_${func.name}`;\n const parameters = typeProvider.getParameters(func);\n\n subject.addFunction({\n name: isFunctionNameReserved ? resolvedName : func.name,\n docs: [func.docs],\n parameters,\n returnType: typeProvider.getFunctionReturnType(func),\n ...(typeProvider.getFunctionOverrideOptions(\n func\n ) as FunctionDeclarationStructure),\n });\n\n if (isFunctionNameReserved) {\n subject.addExportDeclaration({\n namedExports: [\n {\n name: resolvedName,\n alias: func.name,\n },\n ],\n });\n }\n }\n\n let propertiesSubject: ClassDeclaration | null = null;\n\n if (name && apiObject.methods.length > 0) {\n const typeClass = incomingSubject.addClass({\n name,\n });\n propertiesSubject = typeClass;\n\n for (const method of apiObject.methods) {\n const parameters = typeProvider.getParameters(method);\n\n typeClass.addMethod({\n name: method.name,\n docs: [method.docs],\n parameters,\n returnType: typeProvider.getFunctionReturnType(method),\n ...(typeProvider.getFunctionOverrideOptions(\n method\n ) as Partial<MethodDeclarationStructure>),\n });\n }\n }\n\n for (const property of apiObject.properties) {\n const propertyDetails = typeProvider.getPropertyDetails(property);\n\n if (propertiesSubject) {\n propertiesSubject.addProperty({\n name: property.name,\n docs: [property.docs],\n type: propertyDetails.type,\n isStatic: propertyDetails.isStatic,\n isReadonly: propertyDetails.isReadOnly,\n });\n } else {\n subject.addVariableStatement({\n docs: [property.docs],\n declarations: [\n {\n name: property.name,\n type: propertyDetails.type,\n },\n ],\n });\n }\n }\n\n for (const namespace of Object.entries(apiObject.namespaces)) {\n generateNamespace(namespace[1], subject, typeProvider, namespace[0]);\n }\n};\n"],"names":["writeFileSync","useMemo","Project","TypescriptReservedNamed","useGenerateTypeFile","path","definitions","typeProvider","generateTypeFile","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","project","typeFile","createSourceFile","overwrite","globalNamespace","global","addStatements","getGlobalStatements","generateNamespace","getFullText","replace","ready","apiObject","incomingSubject","name","subject","addModule","getStatements","func","functions","isFunctionNameReserved","includes","resolvedName","parameters","getParameters","addFunction","docs","returnType","getFunctionReturnType","getFunctionOverrideOptions","addExportDeclaration","namedExports","alias","propertiesSubject","methods","length","typeClass","addClass","method","addMethod","property","properties","propertyDetails","getPropertyDetails","addProperty","type","isStatic","isReadonly","isReadOnly","addVariableStatement","declarations","namespace","Object","entries","namespaces"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAKIC,OAAO,QAEJ,WAAW;AAElB,SAASC,uBAAuB,QAAQ,qBAAqB;AAG7D,OAAO,MAAMC,sBAAsB,CAC/BC,MACAC,aACAC;IAEA,MAAMC,mBAAmBP,QAAQ;QAC7B,OAAO;YACHQ,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACP,aAAa;oBACd,MAAM,IAAIQ,MAAM;gBACpB;gBAEA,IAAI,CAACP,cAAc;oBACf,MAAM,IAAIO,MAAM;gBACpB;gBAEA,MAAMC,UAAU,IAA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G;QACtC,MAAMC,YAAYvB,gBAAgBwB,QAAQ,CAAC;YACvCvB;QACJ;QACAmB,oBAAoBG;QAEpB,KAAK,MAAME,UAAU1B,UAAUsB,OAAO,CAAE;YACpC,MAAMX,aAAa/B,aAAagC,aAAa,CAACc;YAE9CF,UAAUG,SAAS,CAAC;gBAChBzB,MAAMwB,OAAOxB,IAAI;gBACjBY,MAAM;oBAACY,OAAOZ,IAAI;iBAAC;gBACnBH;gBACAI,YAAYnC,aAAaoC,qBAAqB,CAACU;eAC3C9C,aAAaqC,0BAA0B,CACvCS;QAGZ;IACJ;IAEA,KAAK,MAAME,YAAY5B,UAAU6B,UAAU,CAAE;QACzC,MAAMC,kBAAkBlD,aAAamD,kBAAkB,CAACH;QAExD,IAAIP,mBAAmB;YACnBA,kBAAkBW,WAAW,CAAC;gBAC1B9B,MAAM0B,SAAS1B,IAAI;gBACnBY,MAAM;oBAACc,SAASd,IAAI;iBAAC;gBACrBmB,MAAMH,gBAAgBG,IAAI;gBAC1BC,UAAUJ,gBAAgBI,QAAQ;gBAClCC,YAAYL,gBAAgBM,UAAU;YAC1C;QACJ,OAAO;YACHjC,QAAQkC,oBAAoB,CAAC;gBACzBvB,MAAM;oBAACc,SAASd,IAAI;iBAAC;gBACrBwB,cAAc;oBACV;wBACIpC,MAAM0B,SAAS1B,IAAI;wBACnB+B,MAAMH,gBAAgBG,IAAI;oBAC9B;iBACH;YACL;QACJ;IACJ;IAEA,KAAK,MAAMM,aAAaC,OAAOC,OAAO,CAACzC,UAAU0C,UAAU,EAAG;QAC1D9C,kBAAkB2C,SAAS,CAAC,EAAE,EAAEpC,SAASvB,cAAc2D,SAAS,CAAC,EAAE;IACvE;AACJ"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGenerateTypeFile.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport { useMemo } from 'react';\nimport {\n ClassDeclaration,\n FunctionDeclarationStructure,\n MethodDeclarationStructure,\n ModuleDeclaration,\n Project,\n SourceFile,\n} from 'ts-morph';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport { TypescriptReservedNamed } from '@/cli/constants.js';\nimport { ApiDefinitions, ApiObject, CheckListItem } from '@/cli/types.js';\n\nexport const useGenerateTypeFile = (\n path: string,\n definitions: ApiDefinitions | null,\n typeProvider: ReturnType<typeof createTypeProvider> | null\n) => {\n const generateTypeFile = useMemo(() => {\n return {\n waitingDescription: 'Waiting to generate the type file...',\n errorDescription: 'Failed to generate the type file',\n finishedDescription: () => 'Type file generated',\n runningDescription: 'Generating the type file...',\n runner: async () => {\n if (!definitions) {\n throw new Error('Definitions are not set');\n }\n\n if (!typeProvider) {\n throw new Error('Type provider is not set');\n }\n\n const project = new Project();\n const typeFile = project.createSourceFile(path, '', {\n overwrite: true,\n });\n\n const globalNamespace = definitions.global;\n\n typeFile.addStatements(typeProvider.getGlobalStatements());\n\n generateNamespace(globalNamespace, typeFile, typeProvider, '');\n\n writeFileSync(\n path,\n typeFile.getFullText().replace('/**', '\\n/**')\n );\n },\n ready: definitions !== null && typeProvider !== null,\n } satisfies CheckListItem<void>;\n }, [definitions, typeProvider]);\n\n return {\n generateTypeFile,\n };\n};\n\nconst generateNamespace = (\n apiObject: ApiObject,\n incomingSubject: SourceFile | ModuleDeclaration,\n typeProvider: ReturnType<typeof createTypeProvider>,\n namespace: string,\n name?: string\n) => {\n let subject = incomingSubject;\n const fullNamespaceName = [namespace, name].filter(Boolean).join('.');\n\n if (name) {\n subject = incomingSubject.addModule({\n name,\n });\n }\n\n if (name === 'playdate') {\n subject.addStatements(typeProvider.getStatements());\n }\n\n for (const func of apiObject.functions) {\n const isFunctionNameReserved = TypescriptReservedNamed.includes(\n func.name\n );\n const resolvedName = `_${func.name}`;\n const parameters = typeProvider.getParameters(func);\n\n subject.addFunction({\n name: isFunctionNameReserved ? resolvedName : func.name,\n docs: [func.docs],\n parameters,\n returnType: typeProvider.getFunctionReturnType(func),\n isExported: !!name,\n ...(typeProvider.getFunctionOverrideOptions(\n func\n ) as FunctionDeclarationStructure),\n });\n\n if (isFunctionNameReserved) {\n subject.addExportDeclaration({\n namedExports: [\n {\n name: resolvedName,\n alias: func.name,\n },\n ],\n });\n }\n }\n\n let propertiesSubject: ClassDeclaration | null = null;\n\n if (name && apiObject.methods.length > 0) {\n const typeClass = incomingSubject.addClass({\n name,\n ...typeProvider.getClassOptions(fullNamespaceName),\n });\n propertiesSubject = typeClass;\n\n for (const method of apiObject.methods) {\n const parameters = typeProvider.getParameters(method);\n\n typeClass.addMethod({\n name: method.name,\n docs: [method.docs],\n parameters,\n returnType: typeProvider.getFunctionReturnType(method),\n ...(typeProvider.getFunctionOverrideOptions(\n method\n ) as Partial<MethodDeclarationStructure>),\n });\n }\n }\n\n for (const property of apiObject.properties) {\n const propertyDetails = typeProvider.getPropertyDetails(property);\n\n if (propertiesSubject) {\n propertiesSubject.addProperty({\n name: property.name,\n docs: [property.docs],\n type: propertyDetails.type,\n isStatic: propertyDetails.isStatic,\n isReadonly: propertyDetails.isReadOnly,\n });\n } else {\n subject.addVariableStatement({\n docs: [property.docs],\n declarations: [\n {\n name: property.name,\n type: propertyDetails.type,\n },\n ],\n });\n }\n }\n\n for (const eachNamespace of Object.entries(apiObject.namespaces)) {\n generateNamespace(\n eachNamespace[1],\n subject,\n typeProvider,\n fullNamespaceName,\n eachNamespace[0]\n );\n }\n};\n"],"names":["writeFileSync","useMemo","Project","TypescriptReservedNamed","useGenerateTypeFile","path","definitions","typeProvider","generateTypeFile","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","project","typeFile","createSourceFile","overwrite","globalNamespace","global","addStatements","getGlobalStatements","generateNamespace","getFullText","replace","ready","apiObject","incomingSubject","namespace","name","subject","fullNamespaceName","filter","Boolean","join","addModule","getStatements","func","functions","isFunctionNameReserved","includes","resolvedName","parameters","getParameters","addFunction","docs","returnType","getFunctionReturnType","isExported","getFunctionOverrideOptions","addExportDeclaration","namedExports","alias","propertiesSubject","methods","length","typeClass","addClass","getClassOptions","method","addMethod","property","properties","propertyDetails","getPropertyDetails","addProperty","type","isStatic","isReadonly","isReadOnly","addVariableStatement","declarations","eachNamespace","Object","entries","namespaces"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAKIC,OAAO,QAEJ,WAAW;AAElB,SAASC,uBAAuB,QAAQ,qBAAqB;AAG7D,OAAO,MAAMC,sBAAsB,CAC/BC,MACAC,aACAC;IAEA,MAAMC,mBAAmBP,QAAQ;QAC7B,OAAO;YACHQ,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACP,aAAa;oBACd,MAAM,IAAIQ,MAAM;gBACpB;gBAEA,IAAI,CAACP,cAAc;oBACf,MAAM,IAAIO,MAAM;gBACpB;gBAEA,MAAMC,UAAU,IAAIb;gBACpB,MAAMc,WAAWD,QAAQE,gBAAgB,CAACZ,MAAM,IAAI;oBAChDa,WAAW;gBACf;gBAEA,MAAMC,kBAAkBb,YAAYc,MAAM;gBAE1CJ,SAASK,aAAa,CAACd,aAAae,mBAAmB;gBAEvDC,kBAAkBJ,iBAAiBH,UAAUT,cAAc;gBAE3DP,cACIK,MACAW,SAASQ,WAAW,GAAGC,OAAO,CAAC,OAAO;YAE9C;YACAC,OAAOpB,gBAAgB,QAAQC,iBAAiB;QACpD;IACJ,GAAG;QAACD;QAAaC;KAAa;IAE9B,OAAO;QACHC;IACJ;AACJ,EAAE;AAEF,MAAMe,oBAAoB,CACtBI,WACAC,iBACArB,cACAsB,WACAC;IAEA,IAAIC,UAAUH;IACd,MAAMI,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Aa2C,0BAA0B,CACvCU;QAGZ;IACJ;IAEA,KAAK,MAAME,YAAYnC,UAAUoC,UAAU,CAAE;QACzC,MAAMC,kBAAkBzD,aAAa0D,kBAAkB,CAACH;QAExD,IAAIR,mBAAmB;YACnBA,kBAAkBY,WAAW,CAAC;gBAC1BpC,MAAMgC,SAAShC,IAAI;gBACnBgB,MAAM;oBAACgB,SAAShB,IAAI;iBAAC;gBACrBqB,MAAMH,gBAAgBG,IAAI;gBAC1BC,UAAUJ,gBAAgBI,QAAQ;gBAClCC,YAAYL,gBAAgBM,UAAU;YAC1C;QACJ,OAAO;YACHvC,QAAQwC,oBAAoB,CAAC;gBACzBzB,MAAM;oBAACgB,SAAShB,IAAI;iBAAC;gBACrB0B,cAAc;oBACV;wBACI1C,MAAMgC,SAAShC,IAAI;wBACnBqC,MAAMH,gBAAgBG,IAAI;oBAC9B;iBACH;YACL;QACJ;IACJ;IAEA,KAAK,MAAMM,iBAAiBC,OAAOC,OAAO,CAAChD,UAAUiD,UAAU,EAAG;QAC9DrD,kBACIkD,aAAa,CAAC,EAAE,EAChB1C,SACAxB,cACAyB,mBACAyC,aAAa,CAAC,EAAE;IAExB;AACJ"}
@@ -12,6 +12,7 @@ export declare const useGetVersion: (version: PlaydateSdkVersion) => {
12
12
  typeProvider: {
13
13
  getGlobalStatements: () => string[];
14
14
  getStatements: () => string[];
15
+ getClassOptions: (className: string) => Partial<import("ts-morph").ClassDeclarationStructure>;
15
16
  getPropertyDetails: (property: import("../../../types.js").PropertyDescription) => import("../../../types.js").PropertyDetails;
16
17
  getFunctionReturnType: (func: import("../../../types.js").FunctionDescription) => string;
17
18
  getParameterDetails: (func: import("../../../types.js").FunctionDescription, parameter: string) => import("../../../types.js").ParameterDetails;
@@ -3,6 +3,7 @@ import { FunctionDescription, ParameterDetails, PropertyDescription, PropertyDet
3
3
  export declare const createTypeProvider: (version: string) => {
4
4
  getGlobalStatements: () => string[];
5
5
  getStatements: () => string[];
6
+ getClassOptions: (className: string) => Partial<import("ts-morph").ClassDeclarationStructure>;
6
7
  getPropertyDetails: (property: PropertyDescription) => PropertyDetails;
7
8
  getFunctionReturnType: (func: FunctionDescription) => string;
8
9
  getParameterDetails: (func: FunctionDescription, parameter: string) => ParameterDetails;
@@ -12,17 +12,23 @@ export const createTypeProvider = (version)=>{
12
12
  const fallbackProvider = existsSync(path) ? JSON.parse(readFileSync(path, 'utf-8')) : {
13
13
  globalStatements: [],
14
14
  statements: [],
15
+ classes: {},
15
16
  properties: {},
16
17
  functions: {}
17
18
  };
18
19
  const provider = {
19
20
  globalStatements: fallbackProvider.globalStatements,
20
21
  statements: fallbackProvider.statements,
22
+ classes: fallbackProvider.classes,
21
23
  properties: {},
22
24
  functions: {}
23
25
  };
24
26
  const visitedProperties = new Map();
25
27
  const visitedFunctions = new Map();
28
+ const getClassOptions = (className)=>{
29
+ var _provider_classes_className;
30
+ return (_provider_classes_className = provider.classes[className]) != null ? _provider_classes_className : {};
31
+ };
26
32
  const getPropertyDetails = (property)=>{
27
33
  if (visitedProperties.has(property.signature)) {
28
34
  return visitedProperties.get(property.signature);
@@ -127,6 +133,7 @@ export const createTypeProvider = (version)=>{
127
133
  return {
128
134
  getGlobalStatements,
129
135
  getStatements,
136
+ getClassOptions,
130
137
  getPropertyDetails,
131
138
  getFunctionReturnType,
132
139
  getParameterDetails,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/utils/createTypeProvider.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport { existsSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport {\n FunctionDeclarationStructure,\n ParameterDeclarationStructure,\n StructureKind,\n} from 'ts-morph';\nimport { DataFolder } from '@/cli/constants.js';\nimport {\n FunctionDescription,\n FunctionDetails,\n ParameterDetails,\n PropertyDescription,\n PropertyDetails,\n TypeProviderData,\n} from '@/cli/types.js';\n\nfunction kebabToCamelCase(str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\nexport const createTypeProvider = (version: string) => {\n const path = join(DataFolder, `${version}.json`);\n const fallbackProvider = existsSync(path)\n ? (JSON.parse(readFileSync(path, 'utf-8')) as TypeProviderData)\n : ({\n globalStatements: [],\n statements: [],\n properties: {},\n functions: {},\n } satisfies TypeProviderData);\n const provider = {\n globalStatements: fallbackProvider.globalStatements,\n statements: fallbackProvider.statements,\n properties: {},\n functions: {},\n } as TypeProviderData;\n const visitedProperties = new Map<string, PropertyDetails>();\n const visitedFunctions = new Map<string, FunctionDetails>();\n\n const getPropertyDetails = (property: PropertyDescription) => {\n if (visitedProperties.has(property.signature)) {\n return visitedProperties.get(property.signature) as PropertyDetails;\n }\n\n let result: PropertyDetails;\n let prop = provider.properties[property.signature];\n\n if (!prop) {\n prop = fallbackProvider.properties[property.signature];\n }\n\n if (!prop) {\n const details = {\n signature: property.signature,\n type: 'any',\n } satisfies PropertyDetails;\n\n provider.properties[property.signature] = details;\n\n result = details;\n } else {\n provider.properties[property.signature] = prop;\n\n result = prop;\n }\n\n visitedProperties.set(property.signature, result);\n\n return result;\n };\n\n const getFunctionDetails = (func: FunctionDescription): FunctionDetails => {\n if (visitedFunctions.has(func.signature)) {\n return visitedFunctions.get(func.signature) as FunctionDetails;\n }\n\n let result: FunctionDetails;\n let fn = provider.functions[func.signature];\n\n if (!fn) {\n fn = fallbackProvider.functions[func.signature];\n }\n\n if (!fn) {\n const details = {\n signature: func.signature,\n parameters: func.parameters.map((p) => ({\n name: p.name,\n type: 'any',\n })),\n returnType: 'any',\n } satisfies FunctionDetails;\n\n provider.functions[func.signature] = details;\n\n result = details;\n } else {\n provider.functions[func.signature] = fn;\n\n result = fn;\n }\n\n visitedFunctions.set(func.signature, result);\n\n return result;\n };\n\n const getGlobalStatements = () => {\n return provider.globalStatements;\n };\n\n const getStatements = () => {\n return provider.statements;\n };\n\n const getFunctionReturnType = (func: FunctionDescription) => {\n const { returnType } = getFunctionDetails(func);\n\n return returnType;\n };\n\n const getParameterDetails = (\n func: FunctionDescription,\n parameter: string\n ) => {\n const { parameters } = getFunctionDetails(func);\n const param = parameters.find((p) => p.name === parameter);\n\n if (!param) {\n return {\n name: parameter,\n type: 'any',\n } satisfies ParameterDetails;\n }\n\n return param;\n };\n\n const getParameters = (\n func: FunctionDescription\n ): FunctionDeclarationStructure['parameters'] => {\n const { overrideParameters = false, parameters } =\n getFunctionDetails(func);\n const getParameterFromDetails = (parameter: ParameterDetails) => {\n return {\n kind: StructureKind.Parameter,\n name: kebabToCamelCase(parameter.name),\n type: parameter.type,\n ...(parameter.overrideOptions ?? {}),\n } satisfies ParameterDeclarationStructure;\n };\n\n if (overrideParameters) {\n return parameters.map((details) => {\n return getParameterFromDetails(details);\n });\n }\n\n return func.parameters.map((parameter) => {\n const details = getParameterDetails(func, parameter.name);\n\n return {\n hasQuestionToken: !parameter.required,\n ...getParameterFromDetails(details),\n } satisfies ParameterDeclarationStructure;\n });\n };\n\n const getFunctionOverrideOptions = (func: FunctionDescription) => {\n return getFunctionDetails(func).overrideOptions ?? {};\n };\n\n const save = () => {\n const contents = JSON.stringify(provider, null, 4) + '\\n';\n\n writeFileSync(path, contents, 'utf-8');\n };\n\n return {\n getGlobalStatements,\n getStatements,\n getPropertyDetails,\n getFunctionReturnType,\n getParameterDetails,\n getParameters,\n getFunctionOverrideOptions,\n save,\n };\n};\n"],"names":["readFileSync","existsSync","writeFileSync","join","StructureKind","DataFolder","kebabToCamelCase","str","replace","_","letter","toUpperCase","createTypeProvider","version","path","fallbackProvider","JSON","parse","globalStatements","statements","properties","functions","provider","visitedProperties","Map","visitedFunctions","getPropertyDetails","property","has","signature","get","result","prop","details","type","set","getFunctionDetails","func","fn","parameters","map","p","name","returnType","getGlobalStatements","getStatements","getFunctionReturnType","getParameterDetails","parameter","param","find","getParameters","overrideParameters","getParameterFromDetails","kind","Parameter","overrideOptions","hasQuestionToken","required","getFunctionOverrideOptions","save","contents","stringify"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;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GAAGH,mBAAmBC;QAC1C,MAAMY,QAAQV,WAAWW,IAAI,CAAC,CAACT,IAAMA,EAAEC,IAAI,KAAKM;QAEhD,IAAI,CAACC,OAAO;YACR,OAAO;gBACHP,MAAMM;gBACNd,MAAM;YACV;QACJ;QAEA,OAAOe;IACX;IAEA,MAAME,gBAAgB,CAClBd;QAEA,MAAM,EAAEe,qBAAqB,KAAK,EAAEb,UAAU,EAAE,GAC5CH,mBAAmBC;QACvB,MAAMgB,0BAA0B,CAACL;gBAKrBA;YAJR,OAAO;gBACHM,MAAMlD,cAAcmD,SAAS;gBAC7Bb,MAAMpC,iBAAiB0C,UAAUN,IAAI;gBACrCR,MAAMc,UAAUd,IAAI;eAChBc,CAAAA,6BAAAA,UAAUQ,eAAe,YAAzBR,6BAA6B,CAAC;QAE1C;QAEA,IAAII,oBAAoB;YACpB,OAAOb,WAAWC,GAAG,CAAC,CAACP;gBACnB,OAAOoB,wBAAwBpB;YACnC;QACJ;QAEA,OAAOI,KAAKE,UAAU,CAACC,GAAG,CAAC,CAACQ;YACxB,MAAMf,UAAUc,oBAAoBV,MAAMW,UAAUN,IAAI;YAExD,OAAO;gBACHe,kBAAkB,CAACT,UAAUU,QAAQ;eAClCL,wBAAwBpB;QAEnC;IACJ;IAEA,MAAM0B,6BAA6B,CAACtB;YACzBD;QAAP,OAAOA,CAAAA,sCAAAA,mBAAmBC,MAAMmB,eAAe,YAAxCpB,sCAA4C,CAAC;IACxD;IAEA,MAAMwB,OAAO;QACT,MAAMC,WAAW7C,KAAK8C,SAAS,CAACxC,UAAU,MAAM,KAAK;QAErDpB,cAAcY,MAAM+C,UAAU;IAClC;IAEA,OAAO;QACHjB;QACAC;QACAnB;QACAoB;QACAC;QACAI;QACAQ;QACAC;IACJ;AACJ,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/utils/createTypeProvider.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport { existsSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport {\n FunctionDeclarationStructure,\n ParameterDeclarationStructure,\n StructureKind,\n} from 'ts-morph';\nimport { DataFolder } from '@/cli/constants.js';\nimport {\n FunctionDescription,\n FunctionDetails,\n ParameterDetails,\n PropertyDescription,\n PropertyDetails,\n TypeProviderData,\n} from '@/cli/types.js';\n\nfunction kebabToCamelCase(str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\nexport const createTypeProvider = (version: string) => {\n const path = join(DataFolder, `${version}.json`);\n const fallbackProvider = existsSync(path)\n ? (JSON.parse(readFileSync(path, 'utf-8')) as TypeProviderData)\n : ({\n globalStatements: [],\n statements: [],\n classes: {},\n properties: {},\n functions: {},\n } satisfies TypeProviderData);\n const provider = {\n globalStatements: fallbackProvider.globalStatements,\n statements: fallbackProvider.statements,\n classes: fallbackProvider.classes,\n properties: {},\n functions: {},\n } as TypeProviderData;\n const visitedProperties = new Map<string, PropertyDetails>();\n const visitedFunctions = new Map<string, FunctionDetails>();\n\n const getClassOptions = (className: string) => {\n return provider.classes[className] ?? {};\n };\n\n const getPropertyDetails = (property: PropertyDescription) => {\n if (visitedProperties.has(property.signature)) {\n return visitedProperties.get(property.signature) as PropertyDetails;\n }\n\n let result: PropertyDetails;\n let prop = provider.properties[property.signature];\n\n if (!prop) {\n prop = fallbackProvider.properties[property.signature];\n }\n\n if (!prop) {\n const details = {\n signature: property.signature,\n type: 'any',\n } satisfies PropertyDetails;\n\n provider.properties[property.signature] = details;\n\n result = details;\n } else {\n provider.properties[property.signature] = prop;\n\n result = prop;\n }\n\n visitedProperties.set(property.signature, result);\n\n return result;\n };\n\n const getFunctionDetails = (func: FunctionDescription): FunctionDetails => {\n if (visitedFunctions.has(func.signature)) {\n return visitedFunctions.get(func.signature) as FunctionDetails;\n }\n\n let result: FunctionDetails;\n let fn = provider.functions[func.signature];\n\n if (!fn) {\n fn = fallbackProvider.functions[func.signature];\n }\n\n if (!fn) {\n const details = {\n signature: func.signature,\n parameters: func.parameters.map((p) => ({\n name: p.name,\n type: 'any',\n })),\n returnType: 'any',\n } satisfies FunctionDetails;\n\n provider.functions[func.signature] = details;\n\n result = details;\n } else {\n provider.functions[func.signature] = fn;\n\n result = fn;\n }\n\n visitedFunctions.set(func.signature, result);\n\n return result;\n };\n\n const getGlobalStatements = () => {\n return provider.globalStatements;\n };\n\n const getStatements = () => {\n return provider.statements;\n };\n\n const getFunctionReturnType = (func: FunctionDescription) => {\n const { returnType } = getFunctionDetails(func);\n\n return returnType;\n };\n\n const getParameterDetails = (\n func: FunctionDescription,\n parameter: string\n ) => {\n const { parameters } = getFunctionDetails(func);\n const param = parameters.find((p) => p.name === parameter);\n\n if (!param) {\n return {\n name: parameter,\n type: 'any',\n } satisfies ParameterDetails;\n }\n\n return param;\n };\n\n const getParameters = (\n func: FunctionDescription\n ): FunctionDeclarationStructure['parameters'] => {\n const { overrideParameters = false, parameters } =\n getFunctionDetails(func);\n const getParameterFromDetails = (parameter: ParameterDetails) => {\n return {\n kind: StructureKind.Parameter,\n name: kebabToCamelCase(parameter.name),\n type: parameter.type,\n ...(parameter.overrideOptions ?? {}),\n } satisfies ParameterDeclarationStructure;\n };\n\n if (overrideParameters) {\n return parameters.map((details) => {\n return getParameterFromDetails(details);\n });\n }\n\n return func.parameters.map((parameter) => {\n const details = getParameterDetails(func, parameter.name);\n\n return {\n hasQuestionToken: !parameter.required,\n ...getParameterFromDetails(details),\n } satisfies ParameterDeclarationStructure;\n });\n };\n\n const getFunctionOverrideOptions = (func: FunctionDescription) => {\n return getFunctionDetails(func).overrideOptions ?? {};\n };\n\n const save = () => {\n const contents = JSON.stringify(provider, null, 4) + '\\n';\n\n writeFileSync(path, contents, 'utf-8');\n };\n\n return {\n getGlobalStatements,\n getStatements,\n getClassOptions,\n getPropertyDetails,\n getFunctionReturnType,\n getParameterDetails,\n getParameters,\n getFunctionOverrideOptions,\n save,\n };\n};\n"],"names":["readFileSync","existsSync","writeFileSync","join","StructureKind","DataFolder","kebabToCamelCase","str","replace","_","letter","toUpperCase","createTypeProvider","version","path","fallbackProvider","JSON","parse","globalStatements","statements","classes","properties","functions","provider","visitedProperties","Map","visitedFunctions","getClassOptions","className","getPropertyDetails","property","has","signature","get","result","prop","details","type","set","getFunctionDetails","func","fn","parameters","map","p","name","returnType","getGlobalStatements","getStatements","getFunctionReturnType","getParameterDetails","parameter","param","find","getParameters","overrideParameters","getParameterFromDetails","kind","Parameter","overrideOptions","hasQuestionToken","required","getFunctionOverrideOptions","save","contents","stringify"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,UAAU,EAAEC,aAAa,QAAQ,UAAU;AACpD,SAASC,IAAI,QAAQ,YAAY;AACjC,SAGIC,aAAa,QACV,WAAW;AAClB,SAASC,UAAU,QAAQ,qBAAqB;AAUhD,SAASC,iBAAiBC,GAAW;IACjC,OAAOA,IAAIC,OAAO,CAAC,aAAa,CAACC,GAAGC,SAAWA,OAAOC,WAAW;AACrE;AAEA,OAAO,MAAMC,qBAAqB,CAACC;IAC/B,MAAMC,OAAOX,KAAKE,YAAY,CAAC,EAAEQ,QAAQ,KAAK,CAAC;IAC/C,MAAME,mBAAmBd,WAAWa,QAC7BE,KAAKC,KAAK,CAACjB,aAAac,MAAM,YAC9B;QACGI,kBAAkB,EAAE;QACpBC,YAAY,EAAE;QACdC,SAAS,CAAC;QACVC,YAAY,CAAC;QACbC,WAAW,CAAC;IAChB;IACN,MAAMC,WAAW;QACbL,kBAAkBH,iBAAiBG,gBAAgB;QACnDC,YAAYJ,iBAAiBI,UAAU;QACvCC,SAASL,iBAAiBK,OAAO;QACjCC,YAAY,CAAC;QACbC,WAAW,CAAC;IAChB;IACA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AExD,OAAO;gBACHe,kBAAkB,CAACT,UAAUU,QAAQ;eAClCL,wBAAwBpB;QAEnC;IACJ;IAEA,MAAM0B,6BAA6B,CAACtB;YACzBD;QAAP,OAAOA,CAAAA,sCAAAA,mBAAmBC,MAAMmB,eAAe,YAAxCpB,sCAA4C,CAAC;IACxD;IAEA,MAAMwB,OAAO;QACT,MAAMC,WAAWhD,KAAKiD,SAAS,CAAC1C,UAAU,MAAM,KAAK;QAErDrB,cAAcY,MAAMkD,UAAU;IAClC;IAEA,OAAO;QACHjB;QACAC;QACArB;QACAE;QACAoB;QACAC;QACAI;QACAQ;QACAC;IACJ;AACJ,EAAE"}
package/src/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FunctionDeclarationStructure, MethodDeclarationStructure, ParameterDeclarationStructure } from 'ts-morph';
1
+ import { ClassDeclarationStructure, FunctionDeclarationStructure, MethodDeclarationStructure, ParameterDeclarationStructure } from 'ts-morph';
2
2
  import { Environment } from './environment/dto/Environment.js';
3
3
  import { PlaydateSdkPath } from './environment/path/dto/PlaydateSdkPath.js';
4
4
  export declare enum PlaydateSdkVersionIdentifier {
@@ -84,6 +84,7 @@ export interface FunctionDetails {
84
84
  export type TypeProviderData = {
85
85
  globalStatements: string[];
86
86
  statements: string[];
87
+ classes: Record<string, Partial<ClassDeclarationStructure>>;
87
88
  properties: Record<string, PropertyDetails>;
88
89
  functions: Record<string, FunctionDetails>;
89
90
  };
package/src/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../libs/cli/src/types.ts"],"sourcesContent":["import {\n FunctionDeclarationStructure,\n MethodDeclarationStructure,\n ParameterDeclarationStructure,\n} from 'ts-morph';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { PlaydateSdkPath } from '@/cli/environment/path/dto/PlaydateSdkPath.js';\n\nexport enum PlaydateSdkVersionIdentifier {\n Latest = 'latest',\n}\n\nexport type PlaydateSdkVersion = PlaydateSdkVersionIdentifier.Latest | string;\n\nexport type EnvironmentHealthResult =\n | {\n isHealthy: true;\n environment: Environment;\n health: EnvironmentHealth;\n }\n | {\n isHealthy: false;\n health: EnvironmentHealth;\n };\n\nexport enum HealthCheckStatusType {\n Healthy = 'Healthy',\n Unhealthy = 'Unhealthy',\n Unknown = 'Unknown',\n}\n\nexport type HealthCheckStatus<TArgument> =\n | {\n healthStatus:\n | HealthCheckStatusType.Unknown\n | HealthCheckStatusType.Unhealthy;\n }\n | {\n healthStatus: HealthCheckStatusType.Healthy;\n argument: TArgument;\n };\n\nexport interface EnvironmentHealth {\n sdkPathKnown: HealthCheckStatus<PlaydateSdkPath>;\n}\n\nexport type CheckListItem<TResult> = {\n runningDescription: string;\n waitingDescription: string;\n errorDescription: string;\n finishedDescription: (result: TResult) => string;\n runner: () => Promise<TResult> | Promise<false>;\n onFinish?: (result: TResult) => void;\n ready?: boolean;\n};\n\nexport interface ParameterDescription {\n name: string;\n required: boolean;\n}\n\nexport interface PropertyDescription {\n signature: string;\n name: string;\n namespaces: string[];\n docs: string;\n}\n\nexport interface FunctionDescription {\n signature: string;\n name: string;\n namespaces: string[];\n parameters: ParameterDescription[];\n hasSelf: boolean;\n docs: string;\n}\nexport interface ApiObject {\n functions: FunctionDescription[];\n methods: FunctionDescription[];\n properties: PropertyDescription[];\n namespaces: Record<string, ApiObject>;\n}\n\nexport interface ApiDefinitions {\n global: ApiObject;\n}\n\nexport interface ParameterDetails {\n name: string;\n type: string;\n overrideOptions?: Partial<\n Omit<ParameterDeclarationStructure, 'kind' | 'name' | 'type'>\n >;\n}\n\nexport interface PropertyDetails {\n signature: string;\n type: string;\n isStatic?: boolean;\n isReadOnly?: boolean;\n}\n\nexport interface FunctionDetails {\n signature: string;\n parameters: ParameterDetails[];\n returnType: string;\n overrideParameters?: boolean;\n overrideOptions?: Partial<\n FunctionDeclarationStructure | MethodDeclarationStructure\n >;\n}\n\nexport type TypeProviderData = {\n globalStatements: string[];\n statements: string[];\n properties: Record<string, PropertyDetails>;\n functions: Record<string, FunctionDetails>;\n};\n"],"names":["PlaydateSdkVersionIdentifier","HealthCheckStatusType"],"rangeMappings":";;;;;;;;;","mappings":";UAQYA;;GAAAA,iCAAAA;;UAiBAC;;;;GAAAA,0BAAAA"}
1
+ {"version":3,"sources":["../../../../libs/cli/src/types.ts"],"sourcesContent":["import {\n ClassDeclarationStructure,\n FunctionDeclarationStructure,\n MethodDeclarationStructure,\n ParameterDeclarationStructure,\n} from 'ts-morph';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { PlaydateSdkPath } from '@/cli/environment/path/dto/PlaydateSdkPath.js';\n\nexport enum PlaydateSdkVersionIdentifier {\n Latest = 'latest',\n}\n\nexport type PlaydateSdkVersion = PlaydateSdkVersionIdentifier.Latest | string;\n\nexport type EnvironmentHealthResult =\n | {\n isHealthy: true;\n environment: Environment;\n health: EnvironmentHealth;\n }\n | {\n isHealthy: false;\n health: EnvironmentHealth;\n };\n\nexport enum HealthCheckStatusType {\n Healthy = 'Healthy',\n Unhealthy = 'Unhealthy',\n Unknown = 'Unknown',\n}\n\nexport type HealthCheckStatus<TArgument> =\n | {\n healthStatus:\n | HealthCheckStatusType.Unknown\n | HealthCheckStatusType.Unhealthy;\n }\n | {\n healthStatus: HealthCheckStatusType.Healthy;\n argument: TArgument;\n };\n\nexport interface EnvironmentHealth {\n sdkPathKnown: HealthCheckStatus<PlaydateSdkPath>;\n}\n\nexport type CheckListItem<TResult> = {\n runningDescription: string;\n waitingDescription: string;\n errorDescription: string;\n finishedDescription: (result: TResult) => string;\n runner: () => Promise<TResult> | Promise<false>;\n onFinish?: (result: TResult) => void;\n ready?: boolean;\n};\n\nexport interface ParameterDescription {\n name: string;\n required: boolean;\n}\n\nexport interface PropertyDescription {\n signature: string;\n name: string;\n namespaces: string[];\n docs: string;\n}\n\nexport interface FunctionDescription {\n signature: string;\n name: string;\n namespaces: string[];\n parameters: ParameterDescription[];\n hasSelf: boolean;\n docs: string;\n}\nexport interface ApiObject {\n functions: FunctionDescription[];\n methods: FunctionDescription[];\n properties: PropertyDescription[];\n namespaces: Record<string, ApiObject>;\n}\n\nexport interface ApiDefinitions {\n global: ApiObject;\n}\n\nexport interface ParameterDetails {\n name: string;\n type: string;\n overrideOptions?: Partial<\n Omit<ParameterDeclarationStructure, 'kind' | 'name' | 'type'>\n >;\n}\n\nexport interface PropertyDetails {\n signature: string;\n type: string;\n isStatic?: boolean;\n isReadOnly?: boolean;\n}\n\nexport interface FunctionDetails {\n signature: string;\n parameters: ParameterDetails[];\n returnType: string;\n overrideParameters?: boolean;\n overrideOptions?: Partial<\n FunctionDeclarationStructure | MethodDeclarationStructure\n >;\n}\n\nexport type TypeProviderData = {\n globalStatements: string[];\n statements: string[];\n classes: Record<string, Partial<ClassDeclarationStructure>>;\n properties: Record<string, PropertyDetails>;\n functions: Record<string, FunctionDetails>;\n};\n"],"names":["PlaydateSdkVersionIdentifier","HealthCheckStatusType"],"rangeMappings":";;;;;;;;;","mappings":";UASYA;;GAAAA,iCAAAA;;UAiBAC;;;;GAAAA,0BAAAA"}