Skip to content

Commit d166c4b

Browse files
committed
Updating server function configs to support more properties, allowing for setting description via the config, and fixing bug where tabi tables could not be lowercase
1 parent 5be6c81 commit d166c4b

File tree

7 files changed

+23
-9
lines changed

7 files changed

+23
-9
lines changed

index.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ type Visibility = 'PUBLIC' | 'TENANT' | 'ENVIRONMENT';
66
type PolyDeployable<CustomConfig extends Record<string, any> = {}> = {
77
context: string;
88
name: string;
9+
description?: string;
910
disableAi?: boolean; // Disable use of AI for filling in missing descriptions
1011
} & CustomConfig;
1112

12-
type PolyFunction = PolyDeployable<{ logsEnabled?: boolean; visibility?: Visibility }>;
13+
type PolyFunction = PolyDeployable<{ visibility?: Visibility }>;
1314

1415
export type PolyServerFunction = PolyFunction & {
15-
alwaysOn?: boolean;
16+
alwaysOn?: boolean;
17+
logsEnabled?: boolean;
18+
serverSideAsync?: boolean;
1619
cachePolyLibrary?: boolean;
20+
generateContexts?: string[];
1721
};
1822

1923
export type PolyClientFunction = PolyFunction;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "polyapi",
3-
"version": "0.24.2",
3+
"version": "0.24.3",
44
"description": "Poly is a CLI tool to help create and manage your Poly definitions.",
55
"license": "MIT",
66
"repository": {

src/commands/generate/table.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const buildTableTree = (specs: TableSpecification[]): TableRoot[] => {
3838
const last = contextParts.length - 1;
3939
for (let i = 0; i <= last; i++) {
4040
const name = contextParts[i];
41-
const interfaceName = i === last ? toPascalCase(name) : toPascalCase(contextParts[i]);
41+
const interfaceName = toPascalCase(i === last ? name : contextParts[i]);
4242
const path = contextParts.slice(0, i + 1).join('.');
4343
const parent = i ? contextParts.slice(0, i).join('.') : 'default';
4444
if (schemas[path]) continue;
@@ -81,7 +81,7 @@ const printTableInterface = (table: TableSpecification | string): string => {
8181
};
8282

8383
const printTableNamespace = (schema: JsonSchema, name: string, depth = 1): string => {
84-
return `${ws(depth)}namespace ${name} {${EOL}${
84+
return `${ws(depth)}namespace ${toPascalCase(name)} {${EOL}${
8585
printSchemaAsType(schema, 'Row', depth + 1)
8686
}${EOL}${EOL}${ws(depth + 1)}${
8787
[

src/dependencies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const libraryMinVersionMap: Record<string, VersionT> = {
1111
'ts-node': '5.0.0',
1212
typescript: '4.0.2',
1313
};
14-
const MIN_NODE_VERSION: VersionT = '18.20.5';
14+
const MIN_NODE_VERSION: VersionT = '20.19.3';
1515

1616
const DEFAULT_TS_CONFIG = {
1717
compilerOptions: {

src/deployables.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export type ParsedDeployableConfig = {
4343
context: string;
4444
name: string;
4545
type: DeployableTypes;
46+
description?: string;
4647
disableAi?: boolean;
4748
config: Record<string, any>;
4849
};

src/transpiler.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ const getFunctionDetails = (
367367
const types = parseTSTypes(node, sourceFile);
368368
if (
369369
jsDoc &&
370+
types.params.length === jsDoc.params.length &&
370371
types.params.every(
371372
(p, i) =>
372373
p.type === jsDoc.params[i].type && p.name === jsDoc.params[i].name,
@@ -419,6 +420,14 @@ const parseDeployableFunction = (
419420
): DeployableRecord => {
420421
const [deployments, deploymentCommentRanges] = getDeployComments(sourceFile);
421422
const functionDetails = getFunctionDetails(sourceFile, polyConfig.name);
423+
if (polyConfig.description) {
424+
if (polyConfig.description !== functionDetails.types.description) {
425+
functionDetails.types.description = polyConfig.description;
426+
functionDetails.dirty = true;
427+
}
428+
} else {
429+
polyConfig.description = functionDetails.types.description || '';
430+
}
422431
const dependencies = getDependencies(sourceFile.getFullText(), sourceFile.fileName, baseUrl);
423432
const typeSchemas = generateTypeSchemas(sourceFile.fileName, DeployableTypeEntries.map(d => d[0]), polyConfig.name);
424433
return {

test/generateTables.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ describe('printTableSpecs', () => {
1616
const specs: TableSpecification[] = [
1717
{
1818
'id': 'ad5edb98-9eeb-4bb5-8122-32f9a6f6b512',
19-
'name': 'MyTable',
19+
'name': 'myTable',
2020
'context': 'aaron.testing',
21-
'contextName': 'aaron.testing.MyTable',
21+
'contextName': 'aaron.testing.myTable',
2222
'type': 'table',
2323
'schema': {
2424
'type': 'object',
@@ -109,7 +109,7 @@ describe('printTableSpecs', () => {
109109
' }',
110110
'',
111111
' interface Testing {',
112-
' MyTable: {',
112+
' myTable: {',
113113
' count(query: Aaron.Testing.MyTable.CountQuery): Promise<Aaron.Testing.MyTable.CountResult>;',
114114
' selectMany(query: Aaron.Testing.MyTable.SelectManyQuery): Promise<Aaron.Testing.MyTable.QueryResults>;',
115115
' selectOne(query: Aaron.Testing.MyTable.SelectOneQuery): Promise<Aaron.Testing.MyTable.QueryResult>;',

0 commit comments

Comments
 (0)