Skip to content

Commit

Permalink
use .template.js for that sweet sweet syntax highlighting in gh
Browse files Browse the repository at this point in the history
  • Loading branch information
atierian committed Sep 26, 2024
1 parent b05fbac commit e49417d
Show file tree
Hide file tree
Showing 17 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"build": "tsc && yarn copy-js-resolver-templates",
"watch": "tsc -w",
"clean": "rimraf ./lib",
"copy-js-resolver-templates": "cp ./src/resolvers/*.js.template ./lib/resolvers",
"copy-js-resolver-templates": "cp ./src/resolvers/*.template.js ./lib/resolvers",
"test": "jest",
"extract-api": "ts-node ../../scripts/extract-api.ts"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ConversationDirectiveConfiguration } from '../grapqhl-conversation-tran
* @returns {MappingTemplateProvider} An object containing request and response MappingTemplateProviders.
*/
export const conversationMessageSubscriptionMappingTamplate = (config: ConversationDirectiveConfiguration): MappingTemplateProvider => {
const resolver = fs.readFileSync(path.join(__dirname, 'assistant-messages-subscription-resolver-fn.js.template'), 'utf8');
const resolver = fs.readFileSync(path.join(__dirname, 'assistant-messages-subscription-resolver-fn.template.js'), 'utf8');
const templateName = `Subscription.${config.field.name.value}.assistant-message.js`;
return MappingTemplate.s3MappingFunctionCodeFromString(resolver, templateName);
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ConversationDirectiveConfiguration } from '../grapqhl-conversation-tran
* @returns {MappingTemplateProvider} An object containing request and response MappingTemplateProviders.
*/
export const assistantMutationResolver = (config: ConversationDirectiveConfiguration): MappingTemplateProvider => {
const resolver = fs.readFileSync(path.join(__dirname, 'assistant-mutation-resolver-fn.js.template'), 'utf8');
const resolver = fs.readFileSync(path.join(__dirname, 'assistant-mutation-resolver-fn.template.js'), 'utf8');
const templateName = `Mutation.${config.field.name.value}.assistant-response.js`;
return MappingTemplate.s3MappingFunctionCodeFromString(resolver, templateName);
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ConversationDirectiveConfiguration } from '../grapqhl-conversation-tran
* @returns {MappingTemplateProvider} An object containing request and response MappingTemplateProviders.
*/
export const authMappingTemplate = (config: ConversationDirectiveConfiguration): MappingTemplateProvider => {
const resolver = fs.readFileSync(path.join(__dirname, 'auth-resolver-fn.js.template'), 'utf8');
const resolver = fs.readFileSync(path.join(__dirname, 'auth-resolver-fn.template.js'), 'utf8');
const templateName = `Mutation.${config.field.name.value}.auth.js`;
return MappingTemplate.s3MappingFunctionCodeFromString(resolver, templateName);
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ConversationDirectiveConfiguration } from '../grapqhl-conversation-tran
* @returns {MappingTemplateProvider} An object containing request and response MappingTemplateProviders.
*/
export const initMappingTemplate = (config: ConversationDirectiveConfiguration): MappingTemplateProvider => {
const resolver = fs.readFileSync(path.join(__dirname, 'init-resolver-fn.js.template'), 'utf8');
const resolver = fs.readFileSync(path.join(__dirname, 'init-resolver-fn.template.js'), 'utf8');
const templateName = `Mutation.${config.field.name.value}.init.js`;
return MappingTemplate.s3MappingFunctionCodeFromString(resolver, templateName);
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const invokeLambdaMappingTemplate = (
MESSAGE_MODEL_NAME,
};

let resolver = fs.readFileSync(path.join(__dirname, 'invoke-lambda-resolver-fn.js.template'), 'utf8');
let resolver = fs.readFileSync(path.join(__dirname, 'invoke-lambda-resolver-fn.template.js'), 'utf8');
Object.entries(substitutions).forEach(([key, value]) => {
const replaced = resolver.replace(new RegExp(`\\[\\[${key}\\]\\]`, 'g'), value);
resolver = replaced;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ConversationDirectiveConfiguration } from '../grapqhl-conversation-tran
* @returns {MappingTemplateProvider} An object containing request and response mapping functions.
*/
export const readHistoryMappingTemplate = (config: ConversationDirectiveConfiguration): MappingTemplateProvider => {
const resolver = fs.readFileSync(path.join(__dirname, 'message-history-resolver-fn.js.template'), 'utf8');
const resolver = fs.readFileSync(path.join(__dirname, 'message-history-resolver-fn.template.js'), 'utf8');
const templateName = `Mutation.${config.field.name.value}.message-history.js`;
return MappingTemplate.s3MappingFunctionCodeFromString(resolver, templateName);
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ConversationDirectiveConfiguration } from '../grapqhl-conversation-tran
* @returns {MappingTemplateProvider} An object containing request and response MappingTemplateProviders.
*/
export const verifySessionOwnerMappingTemplate = (config: ConversationDirectiveConfiguration): MappingTemplateProvider => {
const resolver = fs.readFileSync(path.join(__dirname, 'verify-session-owner-resolver-fn.js.template'), 'utf8');
const resolver = fs.readFileSync(path.join(__dirname, 'verify-session-owner-resolver-fn.template.js'), 'utf8');
const templateName = `Mutation.${config.field.name.value}.verify-session-owner.js`;
return MappingTemplate.s3MappingFunctionCodeFromString(resolver, templateName);
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const writeMessageToTableMappingTemplate = (fieldName: string): MappingTe
const substitutions = {
CONVERSATION_MESSAGE_TYPE_NAME: `ConversationMessage${fieldName}`,
};
let resolver = fs.readFileSync(path.join(__dirname, 'write-message-to-table-resolver-fn.js.template'), 'utf8');
let resolver = fs.readFileSync(path.join(__dirname, 'write-message-to-table-resolver-fn.template.js'), 'utf8');
Object.entries(substitutions).forEach(([key, value]) => {
const replaced = resolver.replace(new RegExp(`\\[\\[${key}\\]\\]`, 'g'), value);
resolver = replaced;
Expand Down

0 comments on commit e49417d

Please sign in to comment.