Skip to content

Commit d2164a9

Browse files
4324 p2 add new field cachepolylibrary false to customfunction table if its set to true do the behavior now behind faascachingenabled (#19)
* adds support for cachePolyLibrary for server functions in glide and cache-poly-library flag * increment version
1 parent e176601 commit d2164a9

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

index.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ type PolyDeployable<CustomConfig extends Record<string, any> = {}> = {
1111

1212
type PolyFunction = PolyDeployable<{ logsEnabled?: boolean; visibility?: Visibility }>;
1313

14-
export type PolyServerFunction = PolyFunction & { alwaysOn?: boolean };
14+
export type PolyServerFunction = PolyFunction & {
15+
alwaysOn?: boolean;
16+
cachePolyLibrary?: boolean;
17+
};
1518

1619
export type PolyClientFunction = PolyFunction;
1720

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.0",
3+
"version": "0.24.1",
44
"description": "Poly is a CLI tool to help create and manage your Poly definitions.",
55
"license": "MIT",
66
"repository": {

src/cli.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ void yargs
236236
.option('execution-api-key', {
237237
describe: 'Optional API key for server functions',
238238
type: 'string',
239+
})
240+
.option('cache-poly-library', {
241+
describe: 'Server function only - cache the poly library to improve function performance',
242+
type: 'boolean',
239243
}),
240244
async ({
241245
name,
@@ -247,6 +251,7 @@ void yargs
247251
logs,
248252
generateContexts,
249253
executionApiKey,
254+
cachePolyLibrary,
250255
}) => {
251256
const logsEnabled =
252257
logs === 'enabled' ? true : logs === 'disabled' ? false : undefined;
@@ -266,6 +271,8 @@ void yargs
266271
? 'Invalid value for `logs` option.'
267272
: executionApiKey && !uuidValidate(executionApiKey)
268273
? 'Invalid value for `execution-api-key`. Must be a valid PolyAPI Key.'
274+
: cachePolyLibrary && !server
275+
? 'Option `cache-poly-library` is only for server functions (--server).'
269276
: '';
270277
if (err) {
271278
shell.echo(chalk.redBright('ERROR:'), err);
@@ -286,6 +293,7 @@ void yargs
286293
logsEnabled,
287294
generateContexts,
288295
executionApiKey,
296+
cachePolyLibrary,
289297
);
290298
},
291299
);

src/commands/function.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import fs from 'fs';
32
import chalk from 'chalk';
43
import shell from 'shelljs';
@@ -31,6 +30,7 @@ export const addOrUpdateCustomFunction = async (
3130
logsEnabled: boolean | undefined,
3231
generateContexts: string | undefined,
3332
executionApiKey: string | null | undefined,
33+
cachePolyLibrary: boolean | undefined,
3434
) => {
3535
loadConfig(polyPath);
3636

@@ -96,6 +96,7 @@ export const addOrUpdateCustomFunction = async (
9696
const other: Record<string, any> = {};
9797
if (generateContexts) { other.generateContexts = generateContexts.split(','); }
9898
if (logsEnabled !== undefined) other.logsEnabled = logsEnabled;
99+
if (cachePolyLibrary !== undefined) other.cachePolyLibrary = cachePolyLibrary;
99100

100101
customFunction = await createOrUpdateServerFunction(
101102
context,

0 commit comments

Comments
 (0)