@zapier/zapier-sdk-cli 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cli.cjs +72 -67
- package/dist/cli.mjs +73 -68
- package/dist/index.cjs +71 -66
- package/dist/index.mjs +72 -67
- package/dist/package.json +1 -1
- package/dist/src/plugins/add/ast-generator.d.ts +8 -4
- package/dist/src/plugins/add/ast-generator.js +82 -66
- package/dist/src/plugins/add/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/plugins/add/ast-generator.ts +103 -81
- package/src/plugins/add/index.ts +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @zapier/zapier-sdk-cli
|
|
2
2
|
|
|
3
|
+
## 0.13.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 325d5c2: Fix bug where adding apps with dashed slugs would create types with syntax errors. All valid keys are now valid properties on the apps interface.
|
|
8
|
+
- Updated dependencies [325d5c2]
|
|
9
|
+
- @zapier/zapier-sdk@0.13.2
|
|
10
|
+
- @zapier/zapier-sdk-mcp@0.3.15
|
|
11
|
+
|
|
12
|
+
## 0.13.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [a607e3a]
|
|
17
|
+
- @zapier/zapier-sdk@0.13.1
|
|
18
|
+
- @zapier/zapier-sdk-mcp@0.3.14
|
|
19
|
+
|
|
3
20
|
## 0.13.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/dist/cli.cjs
CHANGED
|
@@ -1604,21 +1604,17 @@ var AstTypeGenerator = class {
|
|
|
1604
1604
|
* Generate TypeScript types using AST for a specific app
|
|
1605
1605
|
*/
|
|
1606
1606
|
async generateTypes(options) {
|
|
1607
|
-
const {
|
|
1608
|
-
const { app, version } = this.parseAppIdentifier(appKey);
|
|
1607
|
+
const { app, authenticationId, sdk: sdk2 } = options;
|
|
1609
1608
|
const actionsResult = await sdk2.listActions({
|
|
1610
|
-
appKey: app
|
|
1609
|
+
appKey: app.implementation_id
|
|
1611
1610
|
});
|
|
1612
1611
|
const actions = actionsResult.data;
|
|
1613
|
-
if (actions.length === 0) {
|
|
1614
|
-
return this.generateEmptyTypesFile(app, version);
|
|
1615
|
-
}
|
|
1616
1612
|
const actionsWithFields = [];
|
|
1617
1613
|
if (authenticationId) {
|
|
1618
1614
|
for (const action of actions) {
|
|
1619
1615
|
try {
|
|
1620
1616
|
const fieldsResult = await sdk2.listInputFields({
|
|
1621
|
-
appKey,
|
|
1617
|
+
appKey: app.implementation_id,
|
|
1622
1618
|
actionKey: action.key,
|
|
1623
1619
|
actionType: action.action_type,
|
|
1624
1620
|
authenticationId
|
|
@@ -1644,7 +1640,7 @@ var AstTypeGenerator = class {
|
|
|
1644
1640
|
...action,
|
|
1645
1641
|
inputFields: [],
|
|
1646
1642
|
name: action.title || action.key,
|
|
1647
|
-
app_key: action.app_key ||
|
|
1643
|
+
app_key: action.app_key || app.implementation_id,
|
|
1648
1644
|
action_type: action.action_type || "write",
|
|
1649
1645
|
title: action.title || action.key,
|
|
1650
1646
|
type: "action",
|
|
@@ -1653,20 +1649,15 @@ var AstTypeGenerator = class {
|
|
|
1653
1649
|
}
|
|
1654
1650
|
);
|
|
1655
1651
|
}
|
|
1656
|
-
const sourceFile = this.createSourceFile(app, actionsWithFields
|
|
1652
|
+
const sourceFile = this.createSourceFile(app, actionsWithFields);
|
|
1657
1653
|
return this.printer.printFile(sourceFile);
|
|
1658
1654
|
}
|
|
1659
|
-
|
|
1660
|
-
const
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
|
-
createSourceFile(appKey, actions, version) {
|
|
1667
|
-
const appName = this.capitalize(appKey);
|
|
1668
|
-
const versionComment = version ? ` * Generated for ${appKey}@${version}` : ` * Generated for ${appKey}`;
|
|
1669
|
-
const headerComment = `Auto-generated TypeScript types for Zapier ${appKey} actions
|
|
1655
|
+
createSourceFile(app, actions) {
|
|
1656
|
+
const appName = this.getPreferredAppName(app);
|
|
1657
|
+
const versionComment = ` * Generated for ${app.implementation_id}`;
|
|
1658
|
+
const preferredKey = this.getPreferredProgrammaticKey(app);
|
|
1659
|
+
const myVariableName = `my${appName}`;
|
|
1660
|
+
const headerComment = `Auto-generated TypeScript types for Zapier ${app.key} actions
|
|
1670
1661
|
${versionComment.slice(3)}
|
|
1671
1662
|
Generated on: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
1672
1663
|
|
|
@@ -1678,11 +1669,11 @@ Usage:
|
|
|
1678
1669
|
|
|
1679
1670
|
const zapier = createZapierSdk();
|
|
1680
1671
|
// Types are automatically available:
|
|
1681
|
-
await zapier.apps.${
|
|
1672
|
+
await zapier.apps.${preferredKey}.search.user_by_email({ authenticationId: 123, inputs: { email } })
|
|
1682
1673
|
|
|
1683
1674
|
// Factory usage (pinned auth):
|
|
1684
|
-
const
|
|
1685
|
-
await
|
|
1675
|
+
const ${myVariableName} = zapier.apps.${preferredKey}({ authenticationId: 123 })
|
|
1676
|
+
await ${myVariableName}.search.user_by_email({ inputs: { email } })`;
|
|
1686
1677
|
const statements = [
|
|
1687
1678
|
// Import the SDK to activate module augmentation
|
|
1688
1679
|
this.createImportStatement(["@zapier/zapier-sdk"]),
|
|
@@ -1720,7 +1711,8 @@ Usage:
|
|
|
1720
1711
|
statements.push(appFactoryInterface);
|
|
1721
1712
|
const appWithFactoryType = this.createAppWithFactoryType(appName);
|
|
1722
1713
|
statements.push(appWithFactoryType);
|
|
1723
|
-
const
|
|
1714
|
+
const allKeys = this.getAllKeys(app);
|
|
1715
|
+
const moduleAugmentation = this.createModuleAugmentation(allKeys, appName);
|
|
1724
1716
|
statements.push(moduleAugmentation);
|
|
1725
1717
|
statements.push(
|
|
1726
1718
|
this.factory.createExportDeclaration(
|
|
@@ -2046,7 +2038,15 @@ Usage:
|
|
|
2046
2038
|
])
|
|
2047
2039
|
);
|
|
2048
2040
|
}
|
|
2049
|
-
createModuleAugmentation(
|
|
2041
|
+
createModuleAugmentation(appKeys, appName) {
|
|
2042
|
+
const properties = appKeys.map(
|
|
2043
|
+
(appKey) => this.factory.createPropertySignature(
|
|
2044
|
+
void 0,
|
|
2045
|
+
this.createPropertyName(appKey),
|
|
2046
|
+
void 0,
|
|
2047
|
+
this.factory.createTypeReferenceNode(`${appName}AppWithFactory`)
|
|
2048
|
+
)
|
|
2049
|
+
);
|
|
2050
2050
|
return this.factory.createModuleDeclaration(
|
|
2051
2051
|
[this.factory.createToken(ts__namespace.SyntaxKind.DeclareKeyword)],
|
|
2052
2052
|
this.factory.createStringLiteral("@zapier/zapier-sdk"),
|
|
@@ -2056,14 +2056,7 @@ Usage:
|
|
|
2056
2056
|
"ZapierSdkApps",
|
|
2057
2057
|
void 0,
|
|
2058
2058
|
void 0,
|
|
2059
|
-
|
|
2060
|
-
this.factory.createPropertySignature(
|
|
2061
|
-
void 0,
|
|
2062
|
-
appKey,
|
|
2063
|
-
void 0,
|
|
2064
|
-
this.factory.createTypeReferenceNode(`${appName}AppWithFactory`)
|
|
2065
|
-
)
|
|
2066
|
-
]
|
|
2059
|
+
properties
|
|
2067
2060
|
)
|
|
2068
2061
|
])
|
|
2069
2062
|
);
|
|
@@ -2101,38 +2094,6 @@ Usage:
|
|
|
2101
2094
|
]);
|
|
2102
2095
|
}
|
|
2103
2096
|
}
|
|
2104
|
-
generateEmptyTypesFile(appKey, version) {
|
|
2105
|
-
const appName = this.capitalize(appKey);
|
|
2106
|
-
const versionComment = version ? ` * Generated for ${appKey}@${version}` : ` * Generated for ${appKey}`;
|
|
2107
|
-
return `/* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/no-explicit-any */
|
|
2108
|
-
/**
|
|
2109
|
-
* Auto-generated TypeScript types for Zapier ${appKey} actions
|
|
2110
|
-
${versionComment}
|
|
2111
|
-
* Generated on: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
2112
|
-
*
|
|
2113
|
-
* No actions found for this app.
|
|
2114
|
-
*/
|
|
2115
|
-
|
|
2116
|
-
import type { ActionExecutionOptions, ActionExecutionResult, ZapierFetchInitOptions } from '@zapier/zapier-sdk'
|
|
2117
|
-
|
|
2118
|
-
interface ${appName}AppProxy {
|
|
2119
|
-
/** Make authenticated HTTP requests through Zapier's Relay service */
|
|
2120
|
-
fetch: (url: string | URL, init?: ZapierFetchInitOptions) => Promise<Response>
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2123
|
-
interface ${appName}AppFactory {
|
|
2124
|
-
(options: { authenticationId: number }): ${appName}AppProxy
|
|
2125
|
-
}
|
|
2126
|
-
|
|
2127
|
-
type ${appName}AppWithFactory = ${appName}AppFactory & ${appName}AppProxy
|
|
2128
|
-
|
|
2129
|
-
declare module "@zapier/zapier-sdk" {
|
|
2130
|
-
interface ZapierSdkApps {
|
|
2131
|
-
${appKey}: ${appName}AppWithFactory
|
|
2132
|
-
}
|
|
2133
|
-
}
|
|
2134
|
-
`;
|
|
2135
|
-
}
|
|
2136
2097
|
capitalize(str) {
|
|
2137
2098
|
return str.charAt(0).toUpperCase() + str.slice(1).replace(/[-_]/g, "");
|
|
2138
2099
|
}
|
|
@@ -2153,6 +2114,50 @@ declare module "@zapier/zapier-sdk" {
|
|
|
2153
2114
|
escapeComment(comment) {
|
|
2154
2115
|
return comment.replace(/\*\//g, "*\\/").replace(/\r?\n/g, " ");
|
|
2155
2116
|
}
|
|
2117
|
+
createPropertyName(name) {
|
|
2118
|
+
if (this.isValidIdentifier(name)) {
|
|
2119
|
+
return this.factory.createIdentifier(name);
|
|
2120
|
+
} else {
|
|
2121
|
+
return this.factory.createStringLiteral(name);
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
isValidIdentifier(name) {
|
|
2125
|
+
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
|
|
2126
|
+
}
|
|
2127
|
+
getPreferredProgrammaticKey(app) {
|
|
2128
|
+
if (app.slug) {
|
|
2129
|
+
const snakeCaseSlug = zapierSdk.toSnakeCase(app.slug);
|
|
2130
|
+
if (this.isValidIdentifier(snakeCaseSlug)) {
|
|
2131
|
+
return snakeCaseSlug;
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
if (this.isValidIdentifier(app.key)) {
|
|
2135
|
+
return app.key;
|
|
2136
|
+
}
|
|
2137
|
+
return this.sanitizeToIdentifier(app.key);
|
|
2138
|
+
}
|
|
2139
|
+
getPreferredAppName(app) {
|
|
2140
|
+
const preferredKey = this.getPreferredProgrammaticKey(app);
|
|
2141
|
+
if (preferredKey.includes("_")) {
|
|
2142
|
+
return preferredKey.split("_").map((word) => this.capitalize(word.toLowerCase())).join("");
|
|
2143
|
+
}
|
|
2144
|
+
return this.capitalize(preferredKey);
|
|
2145
|
+
}
|
|
2146
|
+
sanitizeToIdentifier(name) {
|
|
2147
|
+
let sanitized = name.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
2148
|
+
if (/^[0-9]/.test(sanitized)) {
|
|
2149
|
+
sanitized = "_" + sanitized;
|
|
2150
|
+
}
|
|
2151
|
+
return sanitized;
|
|
2152
|
+
}
|
|
2153
|
+
getAllKeys(app) {
|
|
2154
|
+
const allKeys = /* @__PURE__ */ new Set([app.key]);
|
|
2155
|
+
if (app.slug) {
|
|
2156
|
+
allKeys.add(app.slug);
|
|
2157
|
+
allKeys.add(zapierSdk.toSnakeCase(app.slug));
|
|
2158
|
+
}
|
|
2159
|
+
return Array.from(allKeys);
|
|
2160
|
+
}
|
|
2156
2161
|
};
|
|
2157
2162
|
async function detectTypesOutputDirectory() {
|
|
2158
2163
|
const candidates = ["src", "lib"];
|
|
@@ -2237,7 +2242,7 @@ var addPlugin = ({ sdk: sdk2, context }) => {
|
|
|
2237
2242
|
try {
|
|
2238
2243
|
const generator = new AstTypeGenerator();
|
|
2239
2244
|
const typeDefinitions = await generator.generateTypes({
|
|
2240
|
-
|
|
2245
|
+
app,
|
|
2241
2246
|
authenticationId,
|
|
2242
2247
|
sdk: sdk2
|
|
2243
2248
|
});
|
|
@@ -2284,7 +2289,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
2284
2289
|
|
|
2285
2290
|
// package.json
|
|
2286
2291
|
var package_default = {
|
|
2287
|
-
version: "0.13.
|
|
2292
|
+
version: "0.13.2"};
|
|
2288
2293
|
|
|
2289
2294
|
// src/cli.ts
|
|
2290
2295
|
var program = new commander.Command();
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, createZapierSdkWithoutRegistry, registryPlugin, ZapierError, formatErrorMessage, isPositional } from '@zapier/zapier-sdk';
|
|
4
|
+
import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, createZapierSdkWithoutRegistry, registryPlugin, toSnakeCase, ZapierError, formatErrorMessage, isPositional } from '@zapier/zapier-sdk';
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
6
|
import chalk3 from 'chalk';
|
|
7
7
|
import util from 'util';
|
|
@@ -1571,21 +1571,17 @@ var AstTypeGenerator = class {
|
|
|
1571
1571
|
* Generate TypeScript types using AST for a specific app
|
|
1572
1572
|
*/
|
|
1573
1573
|
async generateTypes(options) {
|
|
1574
|
-
const {
|
|
1575
|
-
const { app, version } = this.parseAppIdentifier(appKey);
|
|
1574
|
+
const { app, authenticationId, sdk: sdk2 } = options;
|
|
1576
1575
|
const actionsResult = await sdk2.listActions({
|
|
1577
|
-
appKey: app
|
|
1576
|
+
appKey: app.implementation_id
|
|
1578
1577
|
});
|
|
1579
1578
|
const actions = actionsResult.data;
|
|
1580
|
-
if (actions.length === 0) {
|
|
1581
|
-
return this.generateEmptyTypesFile(app, version);
|
|
1582
|
-
}
|
|
1583
1579
|
const actionsWithFields = [];
|
|
1584
1580
|
if (authenticationId) {
|
|
1585
1581
|
for (const action of actions) {
|
|
1586
1582
|
try {
|
|
1587
1583
|
const fieldsResult = await sdk2.listInputFields({
|
|
1588
|
-
appKey,
|
|
1584
|
+
appKey: app.implementation_id,
|
|
1589
1585
|
actionKey: action.key,
|
|
1590
1586
|
actionType: action.action_type,
|
|
1591
1587
|
authenticationId
|
|
@@ -1611,7 +1607,7 @@ var AstTypeGenerator = class {
|
|
|
1611
1607
|
...action,
|
|
1612
1608
|
inputFields: [],
|
|
1613
1609
|
name: action.title || action.key,
|
|
1614
|
-
app_key: action.app_key ||
|
|
1610
|
+
app_key: action.app_key || app.implementation_id,
|
|
1615
1611
|
action_type: action.action_type || "write",
|
|
1616
1612
|
title: action.title || action.key,
|
|
1617
1613
|
type: "action",
|
|
@@ -1620,20 +1616,15 @@ var AstTypeGenerator = class {
|
|
|
1620
1616
|
}
|
|
1621
1617
|
);
|
|
1622
1618
|
}
|
|
1623
|
-
const sourceFile = this.createSourceFile(app, actionsWithFields
|
|
1619
|
+
const sourceFile = this.createSourceFile(app, actionsWithFields);
|
|
1624
1620
|
return this.printer.printFile(sourceFile);
|
|
1625
1621
|
}
|
|
1626
|
-
|
|
1627
|
-
const
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
createSourceFile(appKey, actions, version) {
|
|
1634
|
-
const appName = this.capitalize(appKey);
|
|
1635
|
-
const versionComment = version ? ` * Generated for ${appKey}@${version}` : ` * Generated for ${appKey}`;
|
|
1636
|
-
const headerComment = `Auto-generated TypeScript types for Zapier ${appKey} actions
|
|
1622
|
+
createSourceFile(app, actions) {
|
|
1623
|
+
const appName = this.getPreferredAppName(app);
|
|
1624
|
+
const versionComment = ` * Generated for ${app.implementation_id}`;
|
|
1625
|
+
const preferredKey = this.getPreferredProgrammaticKey(app);
|
|
1626
|
+
const myVariableName = `my${appName}`;
|
|
1627
|
+
const headerComment = `Auto-generated TypeScript types for Zapier ${app.key} actions
|
|
1637
1628
|
${versionComment.slice(3)}
|
|
1638
1629
|
Generated on: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
1639
1630
|
|
|
@@ -1645,11 +1636,11 @@ Usage:
|
|
|
1645
1636
|
|
|
1646
1637
|
const zapier = createZapierSdk();
|
|
1647
1638
|
// Types are automatically available:
|
|
1648
|
-
await zapier.apps.${
|
|
1639
|
+
await zapier.apps.${preferredKey}.search.user_by_email({ authenticationId: 123, inputs: { email } })
|
|
1649
1640
|
|
|
1650
1641
|
// Factory usage (pinned auth):
|
|
1651
|
-
const
|
|
1652
|
-
await
|
|
1642
|
+
const ${myVariableName} = zapier.apps.${preferredKey}({ authenticationId: 123 })
|
|
1643
|
+
await ${myVariableName}.search.user_by_email({ inputs: { email } })`;
|
|
1653
1644
|
const statements = [
|
|
1654
1645
|
// Import the SDK to activate module augmentation
|
|
1655
1646
|
this.createImportStatement(["@zapier/zapier-sdk"]),
|
|
@@ -1687,7 +1678,8 @@ Usage:
|
|
|
1687
1678
|
statements.push(appFactoryInterface);
|
|
1688
1679
|
const appWithFactoryType = this.createAppWithFactoryType(appName);
|
|
1689
1680
|
statements.push(appWithFactoryType);
|
|
1690
|
-
const
|
|
1681
|
+
const allKeys = this.getAllKeys(app);
|
|
1682
|
+
const moduleAugmentation = this.createModuleAugmentation(allKeys, appName);
|
|
1691
1683
|
statements.push(moduleAugmentation);
|
|
1692
1684
|
statements.push(
|
|
1693
1685
|
this.factory.createExportDeclaration(
|
|
@@ -2013,7 +2005,15 @@ Usage:
|
|
|
2013
2005
|
])
|
|
2014
2006
|
);
|
|
2015
2007
|
}
|
|
2016
|
-
createModuleAugmentation(
|
|
2008
|
+
createModuleAugmentation(appKeys, appName) {
|
|
2009
|
+
const properties = appKeys.map(
|
|
2010
|
+
(appKey) => this.factory.createPropertySignature(
|
|
2011
|
+
void 0,
|
|
2012
|
+
this.createPropertyName(appKey),
|
|
2013
|
+
void 0,
|
|
2014
|
+
this.factory.createTypeReferenceNode(`${appName}AppWithFactory`)
|
|
2015
|
+
)
|
|
2016
|
+
);
|
|
2017
2017
|
return this.factory.createModuleDeclaration(
|
|
2018
2018
|
[this.factory.createToken(ts.SyntaxKind.DeclareKeyword)],
|
|
2019
2019
|
this.factory.createStringLiteral("@zapier/zapier-sdk"),
|
|
@@ -2023,14 +2023,7 @@ Usage:
|
|
|
2023
2023
|
"ZapierSdkApps",
|
|
2024
2024
|
void 0,
|
|
2025
2025
|
void 0,
|
|
2026
|
-
|
|
2027
|
-
this.factory.createPropertySignature(
|
|
2028
|
-
void 0,
|
|
2029
|
-
appKey,
|
|
2030
|
-
void 0,
|
|
2031
|
-
this.factory.createTypeReferenceNode(`${appName}AppWithFactory`)
|
|
2032
|
-
)
|
|
2033
|
-
]
|
|
2026
|
+
properties
|
|
2034
2027
|
)
|
|
2035
2028
|
])
|
|
2036
2029
|
);
|
|
@@ -2068,38 +2061,6 @@ Usage:
|
|
|
2068
2061
|
]);
|
|
2069
2062
|
}
|
|
2070
2063
|
}
|
|
2071
|
-
generateEmptyTypesFile(appKey, version) {
|
|
2072
|
-
const appName = this.capitalize(appKey);
|
|
2073
|
-
const versionComment = version ? ` * Generated for ${appKey}@${version}` : ` * Generated for ${appKey}`;
|
|
2074
|
-
return `/* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/no-explicit-any */
|
|
2075
|
-
/**
|
|
2076
|
-
* Auto-generated TypeScript types for Zapier ${appKey} actions
|
|
2077
|
-
${versionComment}
|
|
2078
|
-
* Generated on: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
2079
|
-
*
|
|
2080
|
-
* No actions found for this app.
|
|
2081
|
-
*/
|
|
2082
|
-
|
|
2083
|
-
import type { ActionExecutionOptions, ActionExecutionResult, ZapierFetchInitOptions } from '@zapier/zapier-sdk'
|
|
2084
|
-
|
|
2085
|
-
interface ${appName}AppProxy {
|
|
2086
|
-
/** Make authenticated HTTP requests through Zapier's Relay service */
|
|
2087
|
-
fetch: (url: string | URL, init?: ZapierFetchInitOptions) => Promise<Response>
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
interface ${appName}AppFactory {
|
|
2091
|
-
(options: { authenticationId: number }): ${appName}AppProxy
|
|
2092
|
-
}
|
|
2093
|
-
|
|
2094
|
-
type ${appName}AppWithFactory = ${appName}AppFactory & ${appName}AppProxy
|
|
2095
|
-
|
|
2096
|
-
declare module "@zapier/zapier-sdk" {
|
|
2097
|
-
interface ZapierSdkApps {
|
|
2098
|
-
${appKey}: ${appName}AppWithFactory
|
|
2099
|
-
}
|
|
2100
|
-
}
|
|
2101
|
-
`;
|
|
2102
|
-
}
|
|
2103
2064
|
capitalize(str) {
|
|
2104
2065
|
return str.charAt(0).toUpperCase() + str.slice(1).replace(/[-_]/g, "");
|
|
2105
2066
|
}
|
|
@@ -2120,6 +2081,50 @@ declare module "@zapier/zapier-sdk" {
|
|
|
2120
2081
|
escapeComment(comment) {
|
|
2121
2082
|
return comment.replace(/\*\//g, "*\\/").replace(/\r?\n/g, " ");
|
|
2122
2083
|
}
|
|
2084
|
+
createPropertyName(name) {
|
|
2085
|
+
if (this.isValidIdentifier(name)) {
|
|
2086
|
+
return this.factory.createIdentifier(name);
|
|
2087
|
+
} else {
|
|
2088
|
+
return this.factory.createStringLiteral(name);
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
isValidIdentifier(name) {
|
|
2092
|
+
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
|
|
2093
|
+
}
|
|
2094
|
+
getPreferredProgrammaticKey(app) {
|
|
2095
|
+
if (app.slug) {
|
|
2096
|
+
const snakeCaseSlug = toSnakeCase(app.slug);
|
|
2097
|
+
if (this.isValidIdentifier(snakeCaseSlug)) {
|
|
2098
|
+
return snakeCaseSlug;
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
if (this.isValidIdentifier(app.key)) {
|
|
2102
|
+
return app.key;
|
|
2103
|
+
}
|
|
2104
|
+
return this.sanitizeToIdentifier(app.key);
|
|
2105
|
+
}
|
|
2106
|
+
getPreferredAppName(app) {
|
|
2107
|
+
const preferredKey = this.getPreferredProgrammaticKey(app);
|
|
2108
|
+
if (preferredKey.includes("_")) {
|
|
2109
|
+
return preferredKey.split("_").map((word) => this.capitalize(word.toLowerCase())).join("");
|
|
2110
|
+
}
|
|
2111
|
+
return this.capitalize(preferredKey);
|
|
2112
|
+
}
|
|
2113
|
+
sanitizeToIdentifier(name) {
|
|
2114
|
+
let sanitized = name.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
2115
|
+
if (/^[0-9]/.test(sanitized)) {
|
|
2116
|
+
sanitized = "_" + sanitized;
|
|
2117
|
+
}
|
|
2118
|
+
return sanitized;
|
|
2119
|
+
}
|
|
2120
|
+
getAllKeys(app) {
|
|
2121
|
+
const allKeys = /* @__PURE__ */ new Set([app.key]);
|
|
2122
|
+
if (app.slug) {
|
|
2123
|
+
allKeys.add(app.slug);
|
|
2124
|
+
allKeys.add(toSnakeCase(app.slug));
|
|
2125
|
+
}
|
|
2126
|
+
return Array.from(allKeys);
|
|
2127
|
+
}
|
|
2123
2128
|
};
|
|
2124
2129
|
async function detectTypesOutputDirectory() {
|
|
2125
2130
|
const candidates = ["src", "lib"];
|
|
@@ -2204,7 +2209,7 @@ var addPlugin = ({ sdk: sdk2, context }) => {
|
|
|
2204
2209
|
try {
|
|
2205
2210
|
const generator = new AstTypeGenerator();
|
|
2206
2211
|
const typeDefinitions = await generator.generateTypes({
|
|
2207
|
-
|
|
2212
|
+
app,
|
|
2208
2213
|
authenticationId,
|
|
2209
2214
|
sdk: sdk2
|
|
2210
2215
|
});
|
|
@@ -2251,7 +2256,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
2251
2256
|
|
|
2252
2257
|
// package.json
|
|
2253
2258
|
var package_default = {
|
|
2254
|
-
version: "0.13.
|
|
2259
|
+
version: "0.13.2"};
|
|
2255
2260
|
|
|
2256
2261
|
// src/cli.ts
|
|
2257
2262
|
var program = new Command();
|