Skip to content

Commit

Permalink
Add links to doc in jsdocs (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamBergamin authored Jun 22, 2023
1 parent 5c45f96 commit e566f7b
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 14 deletions.
37 changes: 33 additions & 4 deletions scripts/src/templates/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@ import {
} from "./utils.ts";
import { FunctionRecord } from "../types.ts";

const renderJSdoc = (
namespace: string,
callback_id: string,
): string => {
const typescript: string[] = [];
typescript.push("/**");
typescript.push(
`* @see The {@link https://api.slack.com/reference/connectors/${namespace}/${callback_id} ${
getFunctionName(callback_id)
}} documentation.`,
);
typescript.push("*/");
return typescript.join("\n");
};

const renderFunctions = (
namespace: string,
functionRecords: FunctionRecord[],
): string => {
const typescript: string[] = [];
functionRecords.forEach((functionRecord: FunctionRecord) => {
typescript.push(
`${renderJSdoc(namespace, functionRecord.callback_id)}\n${
getFunctionName(functionRecord.callback_id)
}`,
);
});
return `{${typescript.join(",\n")}}`;
};

export const ConnectorModTemplate = (
namespace: string,
functionRecords: FunctionRecord[],
Expand All @@ -21,10 +51,9 @@ export const ConnectorModTemplate = (

typescript.push("");
typescript.push(
`const ${objectName} = { functions: {${
functionRecords.map((dfi) => `${getFunctionName(dfi.callback_id)}`)
.join(",")
}}} as const;`,
`const ${objectName} = { functions: ${
renderFunctions(namespace, functionRecords)
}} as const;`,
);
typescript.push("");
typescript.push(`export default ${objectName};`);
Expand Down
9 changes: 8 additions & 1 deletion src/connectors/calendly/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/** This file was autogenerated. Follow the steps in src/schema/slack/functions/README.md to rebuild **/
import GetMeetingLink from "./functions/get_meeting_link.ts";

const Calendly = { functions: { GetMeetingLink } } as const;
const Calendly = {
functions: {
/**
* @see The {@link https://api.slack.com/reference/connectors/calendly/get_meeting_link GetMeetingLink} documentation.
*/
GetMeetingLink,
},
} as const;

export default Calendly;
13 changes: 12 additions & 1 deletion src/connectors/giphy/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
import GetRandomGif from "./functions/get_random_gif.ts";
import GetTranslatedGif from "./functions/get_translated_gif.ts";

const Giphy = { functions: { GetRandomGif, GetTranslatedGif } } as const;
const Giphy = {
functions: {
/**
* @see The {@link https://api.slack.com/reference/connectors/giphy/get_random_gif GetRandomGif} documentation.
*/
GetRandomGif,
/**
* @see The {@link https://api.slack.com/reference/connectors/giphy/get_translated_gif GetTranslatedGif} documentation.
*/
GetTranslatedGif,
},
} as const;

export default Giphy;
9 changes: 8 additions & 1 deletion src/connectors/github.cloud/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/** This file was autogenerated. Follow the steps in src/schema/slack/functions/README.md to rebuild **/
import CreateIssue from "./functions/create_issue.ts";

const GithubCloud = { functions: { CreateIssue } } as const;
const GithubCloud = {
functions: {
/**
* @see The {@link https://api.slack.com/reference/connectors/github.cloud/create_issue CreateIssue} documentation.
*/
CreateIssue,
},
} as const;

export default GithubCloud;
9 changes: 8 additions & 1 deletion src/connectors/gitlab/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/** This file was autogenerated. Follow the steps in src/schema/slack/functions/README.md to rebuild **/
import CreateIssue from "./functions/create_issue.ts";

const Gitlab = { functions: { CreateIssue } } as const;
const Gitlab = {
functions: {
/**
* @see The {@link https://api.slack.com/reference/connectors/gitlab/create_issue CreateIssue} documentation.
*/
CreateIssue,
},
} as const;

export default Gitlab;
9 changes: 8 additions & 1 deletion src/connectors/google.sheets/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/** This file was autogenerated. Follow the steps in src/schema/slack/functions/README.md to rebuild **/
import AddSpreadsheetRow from "./functions/add_spreadsheet_row.ts";

const GoogleSheets = { functions: { AddSpreadsheetRow } } as const;
const GoogleSheets = {
functions: {
/**
* @see The {@link https://api.slack.com/reference/connectors/google.sheets/add_spreadsheet_row AddSpreadsheetRow} documentation.
*/
AddSpreadsheetRow,
},
} as const;

export default GoogleSheets;
13 changes: 12 additions & 1 deletion src/connectors/jira.cloud/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
import CreateIssue from "./functions/create_issue.ts";
import EditIssue from "./functions/edit_issue.ts";

const JiraCloud = { functions: { CreateIssue, EditIssue } } as const;
const JiraCloud = {
functions: {
/**
* @see The {@link https://api.slack.com/reference/connectors/jira.cloud/create_issue CreateIssue} documentation.
*/
CreateIssue,
/**
* @see The {@link https://api.slack.com/reference/connectors/jira.cloud/edit_issue EditIssue} documentation.
*/
EditIssue,
},
} as const;

export default JiraCloud;
2 changes: 1 addition & 1 deletion src/connectors/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file was autogenerated on Tue Jun 20 2023. Follow the steps in src/schema/slack/functions/README.md to rebuild **/
/** This file was autogenerated on Wed Jun 21 2023. Follow the steps in src/schema/slack/functions/README.md to rebuild **/
import Calendly from "./calendly/mod.ts";
import Giphy from "./giphy/mod.ts";
import GithubCloud from "./github.cloud/mod.ts";
Expand Down
19 changes: 18 additions & 1 deletion src/connectors/pagerduty/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,24 @@ import EscalateIncident from "./functions/escalate_incident.ts";
import ResolveIncident from "./functions/resolve_incident.ts";

const Pagerduty = {
functions: { AddANote, CreateIncident, EscalateIncident, ResolveIncident },
functions: {
/**
* @see The {@link https://api.slack.com/reference/connectors/pagerduty/add_a_note AddANote} documentation.
*/
AddANote,
/**
* @see The {@link https://api.slack.com/reference/connectors/pagerduty/create_incident CreateIncident} documentation.
*/
CreateIncident,
/**
* @see The {@link https://api.slack.com/reference/connectors/pagerduty/escalate_incident EscalateIncident} documentation.
*/
EscalateIncident,
/**
* @see The {@link https://api.slack.com/reference/connectors/pagerduty/resolve_incident ResolveIncident} documentation.
*/
ResolveIncident,
},
} as const;

export default Pagerduty;
15 changes: 14 additions & 1 deletion src/connectors/salesforce/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@ import RunFlow from "./functions/run_flow.ts";
import UpdateRecord from "./functions/update_record.ts";

const Salesforce = {
functions: { CreateRecord, RunFlow, UpdateRecord },
functions: {
/**
* @see The {@link https://api.slack.com/reference/connectors/salesforce/create_record CreateRecord} documentation.
*/
CreateRecord,
/**
* @see The {@link https://api.slack.com/reference/connectors/salesforce/run_flow RunFlow} documentation.
*/
RunFlow,
/**
* @see The {@link https://api.slack.com/reference/connectors/salesforce/update_record UpdateRecord} documentation.
*/
UpdateRecord,
},
} as const;

export default Salesforce;
9 changes: 8 additions & 1 deletion src/connectors/zoom/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/** This file was autogenerated. Follow the steps in src/schema/slack/functions/README.md to rebuild **/
import CreateMeeting from "./functions/create_meeting.ts";

const Zoom = { functions: { CreateMeeting } } as const;
const Zoom = {
functions: {
/**
* @see The {@link https://api.slack.com/reference/connectors/zoom/create_meeting CreateMeeting} documentation.
*/
CreateMeeting,
},
} as const;

export default Zoom;

0 comments on commit e566f7b

Please sign in to comment.