From 9c7b2cf023099061936050dc59e0d01e60d02bf7 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 21 Nov 2024 12:34:19 +0000 Subject: [PATCH] Adding workspace for messages-api-sms-v0.1 --- .../.astro/astro/content.d.ts | 215 ++++++++++++++++++ .../messages_api-sms/ws/.vscode/cleanup.sh | 19 ++ tutorials/messages_api-sms/ws/.vscode/envs.sh | 12 + .../messages_api-sms/ws/.vscode/ofos.json | 6 + .../messages_api-sms/ws/.vscode/settings.json | 10 + .../messages_api-sms/ws/.vscode/tasks.json | 64 ++++++ .../messages_api-sms/ws/createWorkspace.sh | 52 +++++ tutorials/messages_api-sms/ws/send-sms.js | 0 tutorials/messages_api-sms/ws/setup.json | 11 + .../messages_api-sms/ws/tutorial-config.json | 13 ++ tutorials/messages_api-sms/ws/vcr.yml | 8 + 11 files changed, 410 insertions(+) create mode 100755 tutorials/messages_api-sms/ws/.vscode/cleanup.sh create mode 100755 tutorials/messages_api-sms/ws/.vscode/envs.sh create mode 100644 tutorials/messages_api-sms/ws/.vscode/ofos.json create mode 100644 tutorials/messages_api-sms/ws/.vscode/settings.json create mode 100644 tutorials/messages_api-sms/ws/.vscode/tasks.json create mode 100755 tutorials/messages_api-sms/ws/createWorkspace.sh create mode 100644 tutorials/messages_api-sms/ws/send-sms.js create mode 100644 tutorials/messages_api-sms/ws/setup.json create mode 100644 tutorials/messages_api-sms/ws/tutorial-config.json create mode 100644 tutorials/messages_api-sms/ws/vcr.yml diff --git a/tutorials/messages_api-sms/.astro/astro/content.d.ts b/tutorials/messages_api-sms/.astro/astro/content.d.ts index e69de29..9ceeb89 100644 --- a/tutorials/messages_api-sms/.astro/astro/content.d.ts +++ b/tutorials/messages_api-sms/.astro/astro/content.d.ts @@ -0,0 +1,215 @@ +declare module 'astro:content' { + interface Render { + '.mdx': Promise<{ + Content: import('astro').MarkdownInstance<{}>['Content']; + headings: import('astro').MarkdownHeading[]; + remarkPluginFrontmatter: Record; + components: import('astro').MDXInstance<{}>['components']; + }>; + } +} + +declare module 'astro:content' { + interface RenderResult { + Content: import('astro/runtime/server/index.js').AstroComponentFactory; + headings: import('astro').MarkdownHeading[]; + remarkPluginFrontmatter: Record; + } + interface Render { + '.md': Promise; + } + + export interface RenderedContent { + html: string; + metadata?: { + imagePaths: Array; + [key: string]: unknown; + }; + } +} + +declare module 'astro:content' { + type Flatten = T extends { [K: string]: infer U } ? U : never; + + export type CollectionKey = keyof AnyEntryMap; + export type CollectionEntry = Flatten; + + export type ContentCollectionKey = keyof ContentEntryMap; + export type DataCollectionKey = keyof DataEntryMap; + + type AllValuesOf = T extends any ? T[keyof T] : never; + type ValidContentEntrySlug = AllValuesOf< + ContentEntryMap[C] + >['slug']; + + /** @deprecated Use `getEntry` instead. */ + export function getEntryBySlug< + C extends keyof ContentEntryMap, + E extends ValidContentEntrySlug | (string & {}), + >( + collection: C, + // Note that this has to accept a regular string too, for SSR + entrySlug: E, + ): E extends ValidContentEntrySlug + ? Promise> + : Promise | undefined>; + + /** @deprecated Use `getEntry` instead. */ + export function getDataEntryById( + collection: C, + entryId: E, + ): Promise>; + + export function getCollection>( + collection: C, + filter?: (entry: CollectionEntry) => entry is E, + ): Promise; + export function getCollection( + collection: C, + filter?: (entry: CollectionEntry) => unknown, + ): Promise[]>; + + export function getEntry< + C extends keyof ContentEntryMap, + E extends ValidContentEntrySlug | (string & {}), + >(entry: { + collection: C; + slug: E; + }): E extends ValidContentEntrySlug + ? Promise> + : Promise | undefined>; + export function getEntry< + C extends keyof DataEntryMap, + E extends keyof DataEntryMap[C] | (string & {}), + >(entry: { + collection: C; + id: E; + }): E extends keyof DataEntryMap[C] + ? Promise + : Promise | undefined>; + export function getEntry< + C extends keyof ContentEntryMap, + E extends ValidContentEntrySlug | (string & {}), + >( + collection: C, + slug: E, + ): E extends ValidContentEntrySlug + ? Promise> + : Promise | undefined>; + export function getEntry< + C extends keyof DataEntryMap, + E extends keyof DataEntryMap[C] | (string & {}), + >( + collection: C, + id: E, + ): E extends keyof DataEntryMap[C] + ? Promise + : Promise | undefined>; + + /** Resolve an array of entry references from the same collection */ + export function getEntries( + entries: { + collection: C; + slug: ValidContentEntrySlug; + }[], + ): Promise[]>; + export function getEntries( + entries: { + collection: C; + id: keyof DataEntryMap[C]; + }[], + ): Promise[]>; + + export function render( + entry: AnyEntryMap[C][string], + ): Promise; + + export function reference( + collection: C, + ): import('astro/zod').ZodEffects< + import('astro/zod').ZodString, + C extends keyof ContentEntryMap + ? { + collection: C; + slug: ValidContentEntrySlug; + } + : { + collection: C; + id: keyof DataEntryMap[C]; + } + >; + // Allow generic `string` to avoid excessive type errors in the config + // if `dev` is not running to update as you edit. + // Invalid collection names will be caught at build time. + export function reference( + collection: C, + ): import('astro/zod').ZodEffects; + + type ReturnTypeOrOriginal = T extends (...args: any[]) => infer R ? R : T; + type InferEntrySchema = import('astro/zod').infer< + ReturnTypeOrOriginal['schema']> + >; + + type ContentEntryMap = { + "docs": { +"01-welcome.md": { + id: "01-welcome.md"; + slug: "01-welcome"; + body: string; + collection: "docs"; + data: InferEntrySchema<"docs"> +} & { render(): Render[".md"] }; +"02-install-server-sdk.md": { + id: "02-install-server-sdk.md"; + slug: "02-install-server-sdk"; + body: string; + collection: "docs"; + data: InferEntrySchema<"docs"> +} & { render(): Render[".md"] }; +"03-initialize-client.md": { + id: "03-initialize-client.md"; + slug: "03-initialize-client"; + body: string; + collection: "docs"; + data: InferEntrySchema<"docs"> +} & { render(): Render[".md"] }; +"04-send-sms-code.md": { + id: "04-send-sms-code.md"; + slug: "04-send-sms-code"; + body: string; + collection: "docs"; + data: InferEntrySchema<"docs"> +} & { render(): Render[".md"] }; +"05-run-code.md": { + id: "05-run-code.md"; + slug: "05-run-code"; + body: string; + collection: "docs"; + data: InferEntrySchema<"docs"> +} & { render(): Render[".md"] }; +"06-whats-next.md": { + id: "06-whats-next.md"; + slug: "06-whats-next"; + body: string; + collection: "docs"; + data: InferEntrySchema<"docs"> +} & { render(): Render[".md"] }; +"index.mdx": { + id: "index.mdx"; + slug: "index"; + body: string; + collection: "docs"; + data: InferEntrySchema<"docs"> +} & { render(): Render[".mdx"] }; +}; + + }; + + type DataEntryMap = { + + }; + + type AnyEntryMap = ContentEntryMap & DataEntryMap; + + export type ContentConfig = typeof import("../../src/content/config.js"); +} diff --git a/tutorials/messages_api-sms/ws/.vscode/cleanup.sh b/tutorials/messages_api-sms/ws/.vscode/cleanup.sh new file mode 100755 index 0000000..b839553 --- /dev/null +++ b/tutorials/messages_api-sms/ws/.vscode/cleanup.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# First file: Toggle "enabled" between true and false +OFOSFILE="./.vscode/ofos.json" +if [ -f "$OFOSFILE" ]; then + sed -i.bak 's/"enabled": true/"enabled": false/' "$OFOSFILE" + rm -f "${OFOSFILE}.bak" # Remove backup +else + echo "File not found: $OFOSFILE" +fi + +# Second file: Change "runOn": "folderOpen" to "runOn": "default" +TASKSFILE="./.vscode/tasks.json" +if [ -f "$TASKSFILE" ]; then + sed -i.bak 's/"runOn": "folderOpen"/"runOn": "default"/' "$TASKSFILE" + rm -f "${TASKSFILE}.bak" # Remove backup +else + echo "File not found: $TASKSFILE" +fi \ No newline at end of file diff --git a/tutorials/messages_api-sms/ws/.vscode/envs.sh b/tutorials/messages_api-sms/ws/.vscode/envs.sh new file mode 100755 index 0000000..be9a428 --- /dev/null +++ b/tutorials/messages_api-sms/ws/.vscode/envs.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Process YML_ variables +env | grep '^YML_' | while IFS='=' read -r name value; do + new_name=${name#YML_} + export $new_name=\"$value\" +done + +# Write VONAGE_ variables to .env +env | grep -o '^VONAGE_[^=]*' | while read varname; do + echo "$varname=${!varname}" >> .env +done \ No newline at end of file diff --git a/tutorials/messages_api-sms/ws/.vscode/ofos.json b/tutorials/messages_api-sms/ws/.vscode/ofos.json new file mode 100644 index 0000000..e318de8 --- /dev/null +++ b/tutorials/messages_api-sms/ws/.vscode/ofos.json @@ -0,0 +1,6 @@ +{ + "enabled": true, + "startupfiles": [ + "send-sms.js" + ] +} \ No newline at end of file diff --git a/tutorials/messages_api-sms/ws/.vscode/settings.json b/tutorials/messages_api-sms/ws/.vscode/settings.json new file mode 100644 index 0000000..97d70f6 --- /dev/null +++ b/tutorials/messages_api-sms/ws/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "files.exclude": { + "**/.DS_Store": true, + "setup.json": true, + "vcr.yml": true, + }, + "vs-browser.url": "https://neru-febe6726-messages-api-sms-0-1.euw1.runtime.vonage.cloud", + "vs-browser.reload.onSave": false, + "workbench.startupEditor": "none" +} \ No newline at end of file diff --git a/tutorials/messages_api-sms/ws/.vscode/tasks.json b/tutorials/messages_api-sms/ws/.vscode/tasks.json new file mode 100644 index 0000000..08e0423 --- /dev/null +++ b/tutorials/messages_api-sms/ws/.vscode/tasks.json @@ -0,0 +1,64 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "OpenBrowser", + "command": "${input:openBrowser}", + "presentation": { + "reveal": "never", + "close": true + } + }, + { + "label": "OpenTerminal", + "command": "${input:openNewTerminal}", + "presentation": { + "reveal": "never", + "close": true + } + }, + { + "label": "ExportEnv", + "type": "shell", + "command": "chmod +x ./.vscode/envs.sh; ./.vscode/envs.sh", + "presentation": { + "reveal": "never", + "close": true + } + }, + { + "label": "CleanUp", + "type": "shell", + "command": "chmod +x ./.vscode/cleanup.sh; ./.vscode/cleanup.sh", + "presentation": { + "reveal": "never", + "close": true + } + }, + { + "label": "Run", + "dependsOn": [ + "ExportEnv", + "OpenBroswer", + "OpenTerminal", + "CleanUp" + ], + "dependsOrder": "sequence", + "runOptions": { + "runOn": "folderOpen" + } + } + ], + "inputs": [ + { + "id": "openBrowser", + "type": "command", + "command": "vs-browser.start" + }, + { + "id": "openNewTerminal", + "type": "command", + "command": "workbench.action.terminal.new" + } + ] +} diff --git a/tutorials/messages_api-sms/ws/createWorkspace.sh b/tutorials/messages_api-sms/ws/createWorkspace.sh new file mode 100755 index 0000000..7c02b28 --- /dev/null +++ b/tutorials/messages_api-sms/ws/createWorkspace.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +URL=$1 +CONFIG_FILE="tutorial-config.json" + +# Ensure URL is passed as an argument +if [ -z "$1" ]; then + echo "Error: URL must be provided as a parameter. Aborting." + exit 1 +fi + +# Check if CONFIG_FILE exists +if [ ! -f "$CONFIG_FILE" ]; then + echo "Error: Configuration file $CONFIG_FILE not found. Aborting." + exit 1 +fi + +# Read JSON configuration +SLUG=$(jq -r '.slug' "$CONFIG_FILE") +VERSION=$(jq -r '.version' "$CONFIG_FILE") +FILES=$(jq -r '.files[]' "$CONFIG_FILE") +OPEN_FILE=$(jq -r '.openFile' "$CONFIG_FILE") + +# Create files from the "files" array +for FILE in $FILES; do + if [ ! -f "$FILE" ]; then + touch "$FILE" + echo "Created file: $FILE" + else + echo "File already exists: $FILE" + fi +done + +# Update settings.json using a temporary file +SETTINGS_FILE=".vscode/settings.json" +if [ -f "$SETTINGS_FILE" ]; then + TEMP_FILE=$(mktemp) + sed "s|\"vs-browser.url\": \".*\"|\"vs-browser.url\": \"$URL\"|" "$SETTINGS_FILE" > "$TEMP_FILE" && mv "$TEMP_FILE" "$SETTINGS_FILE" + echo "Updated $SETTINGS_FILE with URL: $URL" +else + echo "$SETTINGS_FILE not found." +fi + +# Update ofos.json using a temporary file +OFOS_FILE=".vscode/ofos.json" +if [ -f "$OFOS_FILE" ]; then + TEMP_FILE=$(mktemp) + sed "s||$OPEN_FILE|" "$OFOS_FILE" > "$TEMP_FILE" && mv "$TEMP_FILE" "$OFOS_FILE" + echo "Updated $OFOS_FILE with openFile: $OPEN_FILE" +else + echo "$OFOS_FILE not found." +fi \ No newline at end of file diff --git a/tutorials/messages_api-sms/ws/send-sms.js b/tutorials/messages_api-sms/ws/send-sms.js new file mode 100644 index 0000000..e69de29 diff --git a/tutorials/messages_api-sms/ws/setup.json b/tutorials/messages_api-sms/ws/setup.json new file mode 100644 index 0000000..a479605 --- /dev/null +++ b/tutorials/messages_api-sms/ws/setup.json @@ -0,0 +1,11 @@ +{ + "data": [ + { + "type": "PHONE_NUMBER", + "title": "Vonage Number", + "description": "You need to link a Vonage number for the tutorial.", + "features": ["VOICE", "SMS"], + "name": "VONAGE_NUMBER" + } + ] +} \ No newline at end of file diff --git a/tutorials/messages_api-sms/ws/tutorial-config.json b/tutorials/messages_api-sms/ws/tutorial-config.json new file mode 100644 index 0000000..d143289 --- /dev/null +++ b/tutorials/messages_api-sms/ws/tutorial-config.json @@ -0,0 +1,13 @@ +{ + "title": "Messages API - SMS", + "slug": "messages-api-sms", + "files": [ + "send-sms.js" + ], + "openFile": "send-sms.js", + "panels": [ + "terminal", + "browser" + ], + "version": "0.1" +} \ No newline at end of file diff --git a/tutorials/messages_api-sms/ws/vcr.yml b/tutorials/messages_api-sms/ws/vcr.yml new file mode 100644 index 0000000..213f698 --- /dev/null +++ b/tutorials/messages_api-sms/ws/vcr.yml @@ -0,0 +1,8 @@ +project: + name: tutorial +instance: + name: dev + runtime: nodejs22 + region: aws.euw1 + application-id: 6b3dc652-f374-47eb-856e-5e846a975f5e + entrypoint: [npm, run, start] \ No newline at end of file