From 93a2a9c0a484f72891f0c5467b5df42f4f2308e4 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Thu, 24 Jul 2025 09:41:38 -0600 Subject: [PATCH 1/6] added visibility argument to function add command --- src/api.ts | 5 +++++ src/cli.ts | 11 ++++++++++- src/commands/function.ts | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/api.ts b/src/api.ts index 4f96531..533b370 100644 --- a/src/api.ts +++ b/src/api.ts @@ -25,6 +25,7 @@ import { Specification, SpecificationInputDto, TosDto, + Visibility, WebhookHandleBasicDto, WebhookHandleDescriptionGenerationDto, WebhookHandleDto, @@ -95,6 +96,7 @@ export const createOrUpdateServerFunction = async ( name: string, description: string | null, code: string, + visibility: Visibility, typeSchemas: Record, requirements: string[], other?: Record, @@ -108,6 +110,7 @@ export const createOrUpdateServerFunction = async ( name, description, code, + visibility, typeSchemas, requirements, executionApiKey, @@ -154,6 +157,7 @@ export const createOrUpdateClientFunction = async ( name: string, description: string | null, code: string, + visibility: Visibility, typeSchemas: Record, other?: Record, ) => { @@ -165,6 +169,7 @@ export const createOrUpdateClientFunction = async ( name, description, code, + visibility, typeSchemas, ...other, }, diff --git a/src/cli.ts b/src/cli.ts index 75d9e16..05e01be 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -240,6 +240,10 @@ void yargs .option('cache-poly-library', { describe: 'Server function only - cache the poly library to improve function performance', type: 'boolean', + }) + .option('visibility', { + describe: 'Specifies the visibility of a function. Options: PUBLIC, TENANT, ENVIRONMENT. Case insensitive', + type: 'string', }), async ({ name, @@ -252,9 +256,11 @@ void yargs generateContexts, executionApiKey, cachePolyLibrary, + visibility, }) => { const logsEnabled = logs === 'enabled' ? true : logs === 'disabled' ? false : undefined; + visibility = visibility.toUpperCase(); const err = !name ? 'Missing function name.' : !file @@ -273,7 +279,9 @@ void yargs ? 'Invalid value for `execution-api-key`. Must be a valid PolyAPI Key.' : cachePolyLibrary && !server ? 'Option `cache-poly-library` is only for server functions (--server).' - : ''; + : !["PUBLIC", "TENANT", "ENVIRONMENT"].includes(visibility) + ? 'Option `visibility` must be either PUBLIC, TENANT, or ENVIRONMENT. Case insensitive.' + : ''; if (err) { shell.echo(chalk.redBright('ERROR:'), err); yargs.showHelp(); @@ -294,6 +302,7 @@ void yargs generateContexts, executionApiKey, cachePolyLibrary, + visibility, ); }, ); diff --git a/src/commands/function.ts b/src/commands/function.ts index 65e0a54..34b8999 100644 --- a/src/commands/function.ts +++ b/src/commands/function.ts @@ -4,6 +4,7 @@ import shell from 'shelljs'; import { CreateServerCustomFunctionResponseDto, FunctionDetailsDto, + Visibility, } from '../types'; import { createOrUpdateClientFunction, @@ -31,6 +32,7 @@ export const addOrUpdateCustomFunction = async ( generateContexts: string | undefined, executionApiKey: string | null | undefined, cachePolyLibrary: boolean | undefined, + visibility: string | undefined, ) => { loadConfig(polyPath); @@ -103,6 +105,7 @@ export const addOrUpdateCustomFunction = async ( name, description, code, + Visibility[visibility as keyof typeof Visibility], typeSchemas, dependencies, other, @@ -138,6 +141,7 @@ export const addOrUpdateCustomFunction = async ( name, description, code, + Visibility[visibility as keyof typeof Visibility], typeSchemas, ); shell.echo(chalk.green('DONE')); From fad64d4d32faf5a80eb8e2c246fba5d4680d2203 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Fri, 1 Aug 2025 14:35:11 -0600 Subject: [PATCH 2/6] bumped version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 17d1b65..3bb723f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "polyapi", - "version": "0.24.17", + "version": "0.24.18", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "polyapi", - "version": "0.24.17", + "version": "0.24.18", "license": "MIT", "dependencies": { "@guanghechen/helper-string": "4.7.1", diff --git a/package.json b/package.json index 7fba3c0..4f78374 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polyapi", - "version": "0.24.17", + "version": "0.24.18", "description": "Poly is a CLI tool to help create and manage your Poly definitions.", "license": "MIT", "repository": { From c5a272b1f2bee366730c41231394928da65e7001 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Tue, 5 Aug 2025 08:51:51 -0600 Subject: [PATCH 3/6] Added visibility to sync --- src/commands/sync.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/commands/sync.ts b/src/commands/sync.ts index bf1a927..5b0e2f7 100644 --- a/src/commands/sync.ts +++ b/src/commands/sync.ts @@ -76,6 +76,7 @@ const syncDeployableAndGetId = async (deployable, code) => { deployable.name, deployable.description, code, + deployable.visibility, deployable.typeSchemas, deployable.dependencies, deployable.config, @@ -88,6 +89,7 @@ const syncDeployableAndGetId = async (deployable, code) => { deployable.name, deployable.description, code, + deployable.visibility, deployable.typeSchemas, deployable.config, ) From 3b22eef85ae4d69e76415191a889627768405588 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Wed, 27 Aug 2025 15:57:37 -0700 Subject: [PATCH 4/6] Updated properties and removed enum typecasting --- src/api.ts | 4 ++-- src/cli.ts | 2 +- src/commands/function.ts | 5 ++--- src/commands/sync.ts | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/api.ts b/src/api.ts index 533b370..dca0f2f 100644 --- a/src/api.ts +++ b/src/api.ts @@ -96,7 +96,7 @@ export const createOrUpdateServerFunction = async ( name: string, description: string | null, code: string, - visibility: Visibility, + visibility: string, typeSchemas: Record, requirements: string[], other?: Record, @@ -157,7 +157,7 @@ export const createOrUpdateClientFunction = async ( name: string, description: string | null, code: string, - visibility: Visibility, + visibility: string, typeSchemas: Record, other?: Record, ) => { diff --git a/src/cli.ts b/src/cli.ts index 05e01be..43f78c0 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -260,7 +260,7 @@ void yargs }) => { const logsEnabled = logs === 'enabled' ? true : logs === 'disabled' ? false : undefined; - visibility = visibility.toUpperCase(); + visibility = visibility ? visibility.toUpperCase() : "ENVIRONMENT"; const err = !name ? 'Missing function name.' : !file diff --git a/src/commands/function.ts b/src/commands/function.ts index 34b8999..e54c4ea 100644 --- a/src/commands/function.ts +++ b/src/commands/function.ts @@ -99,13 +99,12 @@ export const addOrUpdateCustomFunction = async ( if (generateContexts) { other.generateContexts = generateContexts.split(','); } if (logsEnabled !== undefined) other.logsEnabled = logsEnabled; if (cachePolyLibrary !== undefined) other.cachePolyLibrary = cachePolyLibrary; - customFunction = await createOrUpdateServerFunction( context, name, description, code, - Visibility[visibility as keyof typeof Visibility], + visibility, typeSchemas, dependencies, other, @@ -141,7 +140,7 @@ export const addOrUpdateCustomFunction = async ( name, description, code, - Visibility[visibility as keyof typeof Visibility], + visibility, typeSchemas, ); shell.echo(chalk.green('DONE')); diff --git a/src/commands/sync.ts b/src/commands/sync.ts index 5b0e2f7..95687aa 100644 --- a/src/commands/sync.ts +++ b/src/commands/sync.ts @@ -76,7 +76,7 @@ const syncDeployableAndGetId = async (deployable, code) => { deployable.name, deployable.description, code, - deployable.visibility, + deployable.config.visibility, deployable.typeSchemas, deployable.dependencies, deployable.config, @@ -89,7 +89,7 @@ const syncDeployableAndGetId = async (deployable, code) => { deployable.name, deployable.description, code, - deployable.visibility, + deployable.config.visibility, deployable.typeSchemas, deployable.config, ) From 035ff1c303f771ea56c1f7e7b8ea780979e45584 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Wed, 27 Aug 2025 15:58:34 -0700 Subject: [PATCH 5/6] bumped version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4f78374..d63b6cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polyapi", - "version": "0.24.18", + "version": "0.24.19", "description": "Poly is a CLI tool to help create and manage your Poly definitions.", "license": "MIT", "repository": { From 5af89d6d49f4dac5f509d54ddbd54034d1bf603c Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Tue, 2 Sep 2025 11:57:12 -0700 Subject: [PATCH 6/6] bumped version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d63b6cf..e29cec1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polyapi", - "version": "0.24.19", + "version": "0.24.20", "description": "Poly is a CLI tool to help create and manage your Poly definitions.", "license": "MIT", "repository": {