Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
5 changes: 5 additions & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
Specification,
SpecificationInputDto,
TosDto,
Visibility,
WebhookHandleBasicDto,
WebhookHandleDescriptionGenerationDto,
WebhookHandleDto,
Expand Down Expand Up @@ -95,6 +96,7 @@ export const createOrUpdateServerFunction = async (
name: string,
description: string | null,
code: string,
visibility: string,
typeSchemas: Record<string, any>,
requirements: string[],
other?: Record<string, any>,
Expand All @@ -108,6 +110,7 @@ export const createOrUpdateServerFunction = async (
name,
description,
code,
visibility,
typeSchemas,
requirements,
executionApiKey,
Expand Down Expand Up @@ -172,6 +175,7 @@ export const createOrUpdateClientFunction = async (
name: string,
description: string | null,
code: string,
visibility: string,
typeSchemas: Record<string, any>,
other?: Record<string, any>,
) => {
Expand All @@ -183,6 +187,7 @@ export const createOrUpdateClientFunction = async (
name,
description,
code,
visibility,
typeSchemas,
...other,
},
Expand Down
11 changes: 10 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -252,9 +256,11 @@ void yargs
generateContexts,
executionApiKey,
cachePolyLibrary,
visibility,
}) => {
const logsEnabled =
logs === 'enabled' ? true : logs === 'disabled' ? false : undefined;
visibility = visibility ? visibility.toUpperCase() : "ENVIRONMENT";
const err = !name
? 'Missing function name.'
: !file
Expand All @@ -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();
Expand All @@ -294,6 +302,7 @@ void yargs
generateContexts,
executionApiKey,
cachePolyLibrary,
visibility,
);
},
);
Expand Down
5 changes: 4 additions & 1 deletion src/commands/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import shell from 'shelljs';
import {
CreateServerCustomFunctionResponseDto,
FunctionDetailsDto,
Visibility,
} from '../types';
import {
createOrUpdateClientFunction,
Expand Down Expand Up @@ -31,6 +32,7 @@ export const addOrUpdateCustomFunction = async (
generateContexts: string | undefined,
executionApiKey: string | null | undefined,
cachePolyLibrary: boolean | undefined,
visibility: string | undefined,
) => {
loadConfig(polyPath);

Expand Down Expand Up @@ -97,12 +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,
typeSchemas,
dependencies,
other,
Expand Down Expand Up @@ -138,6 +140,7 @@ export const addOrUpdateCustomFunction = async (
name,
description,
code,
visibility,
typeSchemas,
);
shell.echo(chalk.green('DONE'));
Expand Down
2 changes: 2 additions & 0 deletions src/commands/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const syncDeployableAndGetId = async (deployable, code) => {
deployable.name,
deployable.description,
code,
deployable.config.visibility,
deployable.typeSchemas,
deployable.dependencies,
deployable.config,
Expand All @@ -94,6 +95,7 @@ const syncDeployableAndGetId = async (deployable, code) => {
deployable.name,
deployable.description,
code,
deployable.config.visibility,
deployable.typeSchemas,
deployable.config,
)
Expand Down