Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
21eff59
some cleanup and bringing over hidden files
aarongoin May 9, 2025
30a4c03
bringing over the deploy workflow
aarongoin May 9, 2025
abacf7c
adding CI/CD workflows
aarongoin May 9, 2025
d3f36ec
updating to use npm cache instead of yarn
aarongoin May 9, 2025
f23457b
Bringing in Richard's updates!
aarongoin May 12, 2025
a40668c
Some missed cleanup, missing dev dependencies, and fixed build.
aarongoin May 13, 2025
6eccb97
hard pinned package versions (#2)
RichardDzurus May 15, 2025
814377f
adding husky pre-commit hook for linting
aarongoin May 15, 2025
2abfc5a
# Feature (4156): P3) Bug with deploying a client function after it a…
sudiptatj May 16, 2025
a221063
Fixing bug where client was not resolving dependencies correctly
aarongoin May 16, 2025
165cdc3
adding missing dependency for testing, and fixing issue where some na…
aarongoin May 16, 2025
40c5236
Handling x-poly-refs contained with function arguments that are thems…
aarongoin May 16, 2025
4178e72
improve logging of failed api function calls (#4)
eupharis May 22, 2025
c1589f1
P2) (MS) npm client: add direct execute option and MTLS option (#3)
RichardDzurus May 22, 2025
d616772
lost my logging in code review, lets go agane (#6)
eupharis May 22, 2025
d2d8376
P3) VSCode Extension: Add a Refresh Button to Tree View #4107 (#5)
sudiptatj May 26, 2025
3d9b821
4372 update contexts info from terminal (#8)
sudiptatj May 28, 2025
5174826
schema generation improvements
aarongoin Jun 4, 2025
7acfeaf
Bumping to 0.23.19 to follow Richard's PR
aarongoin Jun 4, 2025
e00684a
# Feature (2790): P4) Ability to control npx poly generate via an ext…
sudiptatj Jun 5, 2025
540feeb
try new action
eupharis Jun 5, 2025
ae09440
Revert "try new action"
eupharis Jun 5, 2025
5e8275f
Merge branch 'develop' into schema-generation-improvements
aarongoin Jun 5, 2025
3ae8deb
Bug fixes and improvements
aarongoin Jun 5, 2025
ae1bc20
fixing generated webhooks and server functions
aarongoin Jun 10, 2025
858fc89
try a KISS version of auto deploy prebuilt (#12)
eupharis Jun 10, 2025
67b878a
P1) Update typescript client to remove warnings (#7)
RichardDzurus Jun 11, 2025
1c1424d
fix server function runtime
aarongoin Jun 11, 2025
cd07681
downgrade package to fix the wrong export of subpackage issue (#14)
RichardDzurus Jun 12, 2025
7449f61
Improving safety of scrubKeys utility
aarongoin Jun 13, 2025
c03eed7
lets test the auto-update prebuilt functionality
eupharis Jun 16, 2025
eebcdbf
Changed command structure to fix windows glide bug (#15)
Daniel-Estoll Jun 16, 2025
7bb9284
Dirty deployables are now added to git after being updated (#16)
Daniel-Estoll Jun 17, 2025
049d630
Re-fixed glide commit bug (#18)
Daniel-Estoll Jun 18, 2025
e176601
Adding support for tabi tables, and fixing small bug when generating …
aarongoin Jun 18, 2025
d2164a9
4324 p2 add new field cachepolylibrary false to customfunction table …
RichardDzurus Jun 23, 2025
5be6c81
P3) TS Client: Log PolyAPI Library version on function startup (#20)
RichardDzurus Jun 23, 2025
d166c4b
Updating server function configs to support more properties, allowing…
aarongoin Jun 24, 2025
20bba63
4504 p3 glide bug npx poly prepare does not find any deployables in w…
Daniel-Estoll Jun 26, 2025
70e04b7
Making sure api function call errors aren't logged unless LOGS_ENABLE…
aarongoin Jun 26, 2025
c618ecc
Remove the welcome message for now
aarongoin Jun 26, 2025
af440e0
Windows glide duplicate deployables fix (#22)
Daniel-Estoll Jun 30, 2025
01796d8
Removing the updateOne and deleteOne queries from Tabi for now since …
aarongoin Jun 30, 2025
12ea8d3
Merge branch 'main' into develop
aarongoin Jul 1, 2025
a31103f
Warn on schema fallback (#25)
Daniel-Estoll Jul 23, 2025
a20cd0c
added scrubbing to api function requestArgs (#27)
Daniel-Estoll Jul 23, 2025
8849412
Changed import path (#29)
Daniel-Estoll Jul 24, 2025
d0e53d5
Fix scrub import again (#30)
Daniel-Estoll Jul 24, 2025
4a5d7f0
Changed warning message (#31)
Daniel-Estoll Jul 24, 2025
e50e556
assigned scrub to a variable instead of just doing nothing with it (#33)
Daniel-Estoll Jul 25, 2025
ae87976
missed on scrub call to args
eupharis Jul 25, 2025
bce46f8
lets link to the OSS repo doh
eupharis Jul 25, 2025
3dbbe57
fix
eupharis Jul 25, 2025
e59a7e8
Commented out warnings (#34)
Daniel-Estoll Jul 28, 2025
dd58490
Merge branch 'main' into develop
aarongoin Jul 31, 2025
0398daa
bump form-data
aarongoin Aug 22, 2025
6789fe2
fixing glide deployment to also check remote destination to confirm i…
aarongoin Aug 29, 2025
2bfef55
added visibility argument to function add command (#32)
Daniel-Estoll Sep 2, 2025
fbaaeba
Merge branch 'main' into develop
aarongoin Sep 4, 2025
75f8f5e
force image update
eupharis Sep 5, 2025
1c24fc5
Adding support for listening over websockets for gql subscription eve…
aarongoin Sep 22, 2025
9c3c9cd
bumping axios version
aarongoin Oct 2, 2025
179d184
tracking dependencies, also fixing some logging, and adding the updat…
aarongoin Oct 3, 2025
aaed9b9
Separate out public function internal dependencies from non-public ones
aarongoin Oct 10, 2025
e49ab20
fix dependency parsing for client functions, and making new feature w…
aarongoin Oct 10, 2025
89edb10
Fixing type error in the tabi count result type
aarongoin Oct 10, 2025
0a4e6e7
fix small potential bug trying to save specs.json when lib hasn't bee…
aarongoin Oct 13, 2025
f421ab2
keeping backwards compatibility for sfx requirements
aarongoin Oct 16, 2025
094209d
Merge branch 'main' into develop
aarongoin Oct 16, 2025
70ecab7
R27 🚀 (#43)
nahuel-polyapi Oct 16, 2025
7905515
Fixed transpiler to handle case where package.json file does not exist.
aarongoin Oct 17, 2025
6c0e2f5
Turning on strict null checks to prevent bugs like the one I'm fixing…
aarongoin Oct 17, 2025
41d9b89
Revert "Turning on strict null checks to prevent bugs like the one I'…
aarongoin Oct 17, 2025
c72309e
Slimmed down changes for hotfixing
aarongoin Oct 17, 2025
f338610
Generating SDK into temp directory and then swapping it in more atomi…
aarongoin Oct 28, 2025
46367cc
Bump version to deploy sdk generate fix!
aarongoin Oct 28, 2025
c43ea1e
More robust internal dependency parsing
aarongoin Oct 28, 2025
3abbb55
comments
aarongoin Oct 28, 2025
eef51df
Merge branch 'develop'
aarongoin Oct 28, 2025
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ const unregister = poly.myWebhookContext.paymentReceieved(event => {
unregister();
```

Happy hacking!
Happy hacking!
.
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polyapi",
"version": "0.24.20",
"version": "0.25.7",
"description": "Poly is a CLI tool to help create and manage your Poly definitions.",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -51,7 +51,7 @@
"@typescript-eslint/eslint-plugin": "8.32.1",
"@typescript-eslint/parser": "8.32.1",
"adm-zip": "0.5.16",
"axios": "1.8.3",
"axios": "1.12.0",
"chalk": "4.1.2",
"comment-json": "4.2.3",
"dotenv": "16.0.3",
Expand Down
12 changes: 10 additions & 2 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export const createOrUpdateServerFunction = async (
code: string,
visibility: string,
typeSchemas: Record<string, any>,
requirements: string[],
externalDependencies: Record<string, string> | undefined,
internalDependencies: Record<string, Array<{ path: string; id: string }>> | undefined,
other?: Record<string, any>,
executionApiKey?: string,
) => {
Expand All @@ -112,7 +113,10 @@ export const createOrUpdateServerFunction = async (
code,
visibility,
typeSchemas,
requirements,
// Keeping backwards compatability on requirements
requirements: externalDependencies ? Object.keys(externalDependencies) : null,
externalDependencies,
internalDependencies,
executionApiKey,
...other,
},
Expand Down Expand Up @@ -177,6 +181,8 @@ export const createOrUpdateClientFunction = async (
code: string,
visibility: string,
typeSchemas: Record<string, any>,
externalDependencies: Record<string, string> | undefined,
internalDependencies: Record<string, Array<{ path: string; id: string }>> | undefined,
other?: Record<string, any>,
) => {
return (
Expand All @@ -189,6 +195,8 @@ export const createOrUpdateClientFunction = async (
code,
visibility,
typeSchemas,
externalDependencies,
internalDependencies,
...other,
},
{
Expand Down
9 changes: 5 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ void yargs
demandOption: false,
type: 'string',
},
functionIds: {
describe: 'Function IDs to generate',
ids: {
describe: 'Resource IDs to generate',
demandOption: false,
type: 'string',
alias: 'functionIds',
},
customPath: {
describe: 'Custom path to .poly directory (internal use only)',
Expand All @@ -93,7 +94,7 @@ void yargs
exitWhenNoConfig,
contexts,
names,
functionIds,
ids,
customPath = DEFAULT_POLY_PATH,
noTypes = false,
}) => {
Expand All @@ -113,7 +114,7 @@ void yargs
polyPath: customPath,
contexts: contexts?.split(','),
names: names?.split(','),
functionIds: functionIds?.split(','),
ids: ids?.split(','),
noTypes,
});
},
Expand Down
13 changes: 8 additions & 5 deletions src/commands/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ export const addOrUpdateCustomFunction = async (
}

const typeSchemas = generateTypeSchemas(file, DeployableTypeEntries.map(d => d[0]), name);
const [externalDependencies, internalDependencies] = await getDependencies(code, file, tsConfigBaseUrl);

if (server) {
shell.echo(
'-n',
`${updating ? 'Updating' : 'Adding'} custom server side function...`,
);

const dependencies = getDependencies(code, file, tsConfigBaseUrl);
if (dependencies.length) {
if (externalDependencies) {
shell.echo(
chalk.yellow(
'Please note that deploying your functions will take a few minutes because it makes use of libraries other than polyapi.',
Expand All @@ -106,7 +106,8 @@ export const addOrUpdateCustomFunction = async (
code,
visibility,
typeSchemas,
dependencies,
externalDependencies,
internalDependencies,
other,
executionApiKey,
);
Expand Down Expand Up @@ -142,14 +143,16 @@ export const addOrUpdateCustomFunction = async (
code,
visibility,
typeSchemas,
externalDependencies,
internalDependencies,
);
shell.echo(chalk.green('DONE'));
shell.echo(`Client Function ID: ${customFunction.id}`);
}

await generateSingleCustomFunction(polyPath, customFunction.id, updating);
} catch (e) {
shell.echo(chalk.red('ERROR\n'));
shell.echo(`${e.response?.data?.message || e.message}`);
shell.echo(chalk.redBright('ERROR\n'));
shell.echo(chalk.red((e instanceof Error ? e.message : e.response?.data?.message) || 'Unexpected error.'));
}
};
72 changes: 51 additions & 21 deletions src/commands/generate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ApiFunctionSpecification,
AuthFunctionSpecification,
CustomFunctionSpecification,
GraphQLSubscriptionSpecification,
ServerFunctionSpecification,
ServerVariableSpecification,
Specification,
Expand All @@ -17,10 +18,9 @@ import {
import { getSpecs } from '../../api';
import { loadConfig, addOrUpdateConfig } from '../../config';
import {
generateContextDataFile,
getContextDataFileContent,
writeCachedSpecs,
getCachedSpecs,
getPolyLibPath,
getSpecsFromContextData,
showErrGettingSpecs,
getStringPaths,
loadTemplate,
Expand Down Expand Up @@ -53,15 +53,17 @@ const getApiBaseUrl = () =>

const getApiKey = () => process.env.POLY_API_KEY;

const prepareDir = async (polyPath: string) => {
const libPath = getPolyLibPath(polyPath);
const prepareDir = async (polyPath: string, temp = false) => {
let libPath = getPolyLibPath(polyPath);
if (temp) libPath = libPath.replace('/lib', '/temp');

fs.rmSync(libPath, { recursive: true, force: true });
fs.mkdirSync(libPath, { recursive: true });
fs.mkdirSync(`${libPath}/api`);
fs.mkdirSync(`${libPath}/client`);
fs.mkdirSync(`${libPath}/auth`);
fs.mkdirSync(`${libPath}/webhooks`);
fs.mkdirSync(`${libPath}/subscriptions`);
fs.mkdirSync(`${libPath}/server`);
fs.mkdirSync(`${libPath}/vari`);
fs.mkdirSync(`${libPath}/tabi`);
Expand Down Expand Up @@ -144,6 +146,9 @@ const generateJSFiles = async (
const tables = specs.filter(
(spec) => spec.type === 'table',
) as TableSpecification[];
const gqlSubscriptions = specs.filter(
(spec) => spec.type === 'graphqlSubscription',
) as GraphQLSubscriptionSpecification[];

await generateIndexJSFile(libPath);
await generatePolyCustomJSFile(libPath);
Expand All @@ -158,6 +163,7 @@ const generateJSFiles = async (
'custom functions',
);
await tryAsync(generateWebhooksJSFiles(libPath, webhookHandles), 'webhooks');
await tryAsync(generateGraphQLSubscriptionJSFiles(libPath, gqlSubscriptions), 'GraphQL subscriptions');
await tryAsync(
generateAuthFunctionJSFiles(libPath, authFunctions),
'auth functions',
Expand Down Expand Up @@ -284,6 +290,21 @@ const generateWebhooksJSFiles = async (
fs.copyFileSync(templateUrl('webhooks-index.js'), `${libPath}/webhooks/index.js`);
};

const generateGraphQLSubscriptionJSFiles = async (
libPath: string,
specifications: GraphQLSubscriptionSpecification[],
) => {
const template = handlebars.compile(loadTemplate('graphql-subscriptions.js.hbs'));
fs.writeFileSync(
`${libPath}/subscriptions/subscriptions.js`,
template({
specifications,
apiKey: getApiKey(),
}),
);
fs.copyFileSync(templateUrl('graphql-subscriptions-index.js'), `${libPath}/subscriptions/index.js`);
}

const generateServerFunctionJSFiles = async (
libPath: string,
specifications: ServerFunctionSpecification[],
Expand Down Expand Up @@ -441,11 +462,11 @@ const generateSingleCustomFunction = async (
updated ? 'Regenerating TypeScript SDK...' : 'Generating TypeScript SDK...',
);

const libPath = getPolyLibPath(polyPath);
let contextData: Record<string, any> = {};
let libPath = getPolyLibPath(polyPath);
let prevSpecs: Specification[] = [];

try {
contextData = getContextDataFileContent(libPath);
prevSpecs = getCachedSpecs(libPath);
} catch (error) {
shell.echo(chalk.red('ERROR'));
shell.echo('Error while fetching local context data.');
Expand All @@ -454,8 +475,6 @@ const generateSingleCustomFunction = async (
return;
}

const prevSpecs = getSpecsFromContextData(contextData);

let specs: Specification[] = [];

try {
Expand All @@ -479,11 +498,18 @@ const generateSingleCustomFunction = async (
specs = prevSpecs;
}

await prepareDir(polyPath);
await prepareDir(polyPath, true);
libPath = getPolyLibPath(polyPath);
const tempPath = libPath.replace('/lib', '/temp');

writeCachedSpecs(tempPath, specs);

setGenerationErrors(false);

await generateSpecs(libPath, specs, noTypes);
await generateSpecs(tempPath, specs, noTypes);
// Now remove old lib and rename temp directory to force a switchover in typescript
fs.rmSync(libPath, { recursive: true, force: true });
fs.renameSync(tempPath, libPath);

if (getGenerationErrors()) {
shell.echo(
Expand Down Expand Up @@ -532,13 +558,13 @@ const generate = async ({
polyPath,
contexts,
names,
functionIds,
ids,
noTypes,
}: {
polyPath: string;
contexts?: string[];
names?: string[];
functionIds?: string[];
ids?: string[];
noTypes: boolean;
}) => {
let specs: Specification[] = [];
Expand All @@ -548,20 +574,26 @@ const generate = async ({
: 'Generating Poly TypeScript SDK...';
shell.echo('-n', generateMsg);

await prepareDir(polyPath);
await prepareDir(polyPath, true);
loadConfig(polyPath);

try {
specs = await getSpecs(contexts, names, functionIds, noTypes);
const libPath = getPolyLibPath(polyPath);
const tempPath = libPath.replace('/lib', '/temp');

updateLocalConfig(polyPath, contexts, names, functionIds, noTypes);
try {
specs = await getSpecs(contexts, names, ids, noTypes);
writeCachedSpecs(tempPath, specs);
updateLocalConfig(polyPath, contexts, names, ids, noTypes);
} catch (error) {
showErrGettingSpecs(error);
return;
}

setGenerationErrors(false);
await generateSpecs(getPolyLibPath(polyPath), specs, noTypes);
await generateSpecs(tempPath, specs, noTypes);
// Now remove old lib and rename temp directory to force a switchover in typescript
fs.rmSync(libPath, { recursive: true, force: true });
fs.renameSync(tempPath, libPath);

if (getGenerationErrors()) {
shell.echo(
Expand Down Expand Up @@ -638,8 +670,6 @@ export const generateSpecs = async (
);
}

generateContextDataFile(libPath, filteredSpecs);

if (missingNames.length) {
setGenerationErrors(true);
missingNames.map((s) => echoGenerationError(s));
Expand Down
2 changes: 1 addition & 1 deletion src/commands/generate/schemaTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ const printSchemaTreeAsTypes = (
depth + 1,
);
} catch (err) {
console.error(err);
shell.echo(chalk.red(err));
echoGenerationError(child as SchemaSpec);
setGenerationErrors(true);
}
Expand Down
Loading