Skip to content

Commit 9c7b2cf

Browse files
committed
Adding workspace for messages-api-sms-v0.1
1 parent 42d9c2a commit 9c7b2cf

File tree

11 files changed

+410
-0
lines changed

11 files changed

+410
-0
lines changed
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
declare module 'astro:content' {
2+
interface Render {
3+
'.mdx': Promise<{
4+
Content: import('astro').MarkdownInstance<{}>['Content'];
5+
headings: import('astro').MarkdownHeading[];
6+
remarkPluginFrontmatter: Record<string, any>;
7+
components: import('astro').MDXInstance<{}>['components'];
8+
}>;
9+
}
10+
}
11+
12+
declare module 'astro:content' {
13+
interface RenderResult {
14+
Content: import('astro/runtime/server/index.js').AstroComponentFactory;
15+
headings: import('astro').MarkdownHeading[];
16+
remarkPluginFrontmatter: Record<string, any>;
17+
}
18+
interface Render {
19+
'.md': Promise<RenderResult>;
20+
}
21+
22+
export interface RenderedContent {
23+
html: string;
24+
metadata?: {
25+
imagePaths: Array<string>;
26+
[key: string]: unknown;
27+
};
28+
}
29+
}
30+
31+
declare module 'astro:content' {
32+
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
33+
34+
export type CollectionKey = keyof AnyEntryMap;
35+
export type CollectionEntry<C extends CollectionKey> = Flatten<AnyEntryMap[C]>;
36+
37+
export type ContentCollectionKey = keyof ContentEntryMap;
38+
export type DataCollectionKey = keyof DataEntryMap;
39+
40+
type AllValuesOf<T> = T extends any ? T[keyof T] : never;
41+
type ValidContentEntrySlug<C extends keyof ContentEntryMap> = AllValuesOf<
42+
ContentEntryMap[C]
43+
>['slug'];
44+
45+
/** @deprecated Use `getEntry` instead. */
46+
export function getEntryBySlug<
47+
C extends keyof ContentEntryMap,
48+
E extends ValidContentEntrySlug<C> | (string & {}),
49+
>(
50+
collection: C,
51+
// Note that this has to accept a regular string too, for SSR
52+
entrySlug: E,
53+
): E extends ValidContentEntrySlug<C>
54+
? Promise<CollectionEntry<C>>
55+
: Promise<CollectionEntry<C> | undefined>;
56+
57+
/** @deprecated Use `getEntry` instead. */
58+
export function getDataEntryById<C extends keyof DataEntryMap, E extends keyof DataEntryMap[C]>(
59+
collection: C,
60+
entryId: E,
61+
): Promise<CollectionEntry<C>>;
62+
63+
export function getCollection<C extends keyof AnyEntryMap, E extends CollectionEntry<C>>(
64+
collection: C,
65+
filter?: (entry: CollectionEntry<C>) => entry is E,
66+
): Promise<E[]>;
67+
export function getCollection<C extends keyof AnyEntryMap>(
68+
collection: C,
69+
filter?: (entry: CollectionEntry<C>) => unknown,
70+
): Promise<CollectionEntry<C>[]>;
71+
72+
export function getEntry<
73+
C extends keyof ContentEntryMap,
74+
E extends ValidContentEntrySlug<C> | (string & {}),
75+
>(entry: {
76+
collection: C;
77+
slug: E;
78+
}): E extends ValidContentEntrySlug<C>
79+
? Promise<CollectionEntry<C>>
80+
: Promise<CollectionEntry<C> | undefined>;
81+
export function getEntry<
82+
C extends keyof DataEntryMap,
83+
E extends keyof DataEntryMap[C] | (string & {}),
84+
>(entry: {
85+
collection: C;
86+
id: E;
87+
}): E extends keyof DataEntryMap[C]
88+
? Promise<DataEntryMap[C][E]>
89+
: Promise<CollectionEntry<C> | undefined>;
90+
export function getEntry<
91+
C extends keyof ContentEntryMap,
92+
E extends ValidContentEntrySlug<C> | (string & {}),
93+
>(
94+
collection: C,
95+
slug: E,
96+
): E extends ValidContentEntrySlug<C>
97+
? Promise<CollectionEntry<C>>
98+
: Promise<CollectionEntry<C> | undefined>;
99+
export function getEntry<
100+
C extends keyof DataEntryMap,
101+
E extends keyof DataEntryMap[C] | (string & {}),
102+
>(
103+
collection: C,
104+
id: E,
105+
): E extends keyof DataEntryMap[C]
106+
? Promise<DataEntryMap[C][E]>
107+
: Promise<CollectionEntry<C> | undefined>;
108+
109+
/** Resolve an array of entry references from the same collection */
110+
export function getEntries<C extends keyof ContentEntryMap>(
111+
entries: {
112+
collection: C;
113+
slug: ValidContentEntrySlug<C>;
114+
}[],
115+
): Promise<CollectionEntry<C>[]>;
116+
export function getEntries<C extends keyof DataEntryMap>(
117+
entries: {
118+
collection: C;
119+
id: keyof DataEntryMap[C];
120+
}[],
121+
): Promise<CollectionEntry<C>[]>;
122+
123+
export function render<C extends keyof AnyEntryMap>(
124+
entry: AnyEntryMap[C][string],
125+
): Promise<RenderResult>;
126+
127+
export function reference<C extends keyof AnyEntryMap>(
128+
collection: C,
129+
): import('astro/zod').ZodEffects<
130+
import('astro/zod').ZodString,
131+
C extends keyof ContentEntryMap
132+
? {
133+
collection: C;
134+
slug: ValidContentEntrySlug<C>;
135+
}
136+
: {
137+
collection: C;
138+
id: keyof DataEntryMap[C];
139+
}
140+
>;
141+
// Allow generic `string` to avoid excessive type errors in the config
142+
// if `dev` is not running to update as you edit.
143+
// Invalid collection names will be caught at build time.
144+
export function reference<C extends string>(
145+
collection: C,
146+
): import('astro/zod').ZodEffects<import('astro/zod').ZodString, never>;
147+
148+
type ReturnTypeOrOriginal<T> = T extends (...args: any[]) => infer R ? R : T;
149+
type InferEntrySchema<C extends keyof AnyEntryMap> = import('astro/zod').infer<
150+
ReturnTypeOrOriginal<Required<ContentConfig['collections'][C]>['schema']>
151+
>;
152+
153+
type ContentEntryMap = {
154+
"docs": {
155+
"01-welcome.md": {
156+
id: "01-welcome.md";
157+
slug: "01-welcome";
158+
body: string;
159+
collection: "docs";
160+
data: InferEntrySchema<"docs">
161+
} & { render(): Render[".md"] };
162+
"02-install-server-sdk.md": {
163+
id: "02-install-server-sdk.md";
164+
slug: "02-install-server-sdk";
165+
body: string;
166+
collection: "docs";
167+
data: InferEntrySchema<"docs">
168+
} & { render(): Render[".md"] };
169+
"03-initialize-client.md": {
170+
id: "03-initialize-client.md";
171+
slug: "03-initialize-client";
172+
body: string;
173+
collection: "docs";
174+
data: InferEntrySchema<"docs">
175+
} & { render(): Render[".md"] };
176+
"04-send-sms-code.md": {
177+
id: "04-send-sms-code.md";
178+
slug: "04-send-sms-code";
179+
body: string;
180+
collection: "docs";
181+
data: InferEntrySchema<"docs">
182+
} & { render(): Render[".md"] };
183+
"05-run-code.md": {
184+
id: "05-run-code.md";
185+
slug: "05-run-code";
186+
body: string;
187+
collection: "docs";
188+
data: InferEntrySchema<"docs">
189+
} & { render(): Render[".md"] };
190+
"06-whats-next.md": {
191+
id: "06-whats-next.md";
192+
slug: "06-whats-next";
193+
body: string;
194+
collection: "docs";
195+
data: InferEntrySchema<"docs">
196+
} & { render(): Render[".md"] };
197+
"index.mdx": {
198+
id: "index.mdx";
199+
slug: "index";
200+
body: string;
201+
collection: "docs";
202+
data: InferEntrySchema<"docs">
203+
} & { render(): Render[".mdx"] };
204+
};
205+
206+
};
207+
208+
type DataEntryMap = {
209+
210+
};
211+
212+
type AnyEntryMap = ContentEntryMap & DataEntryMap;
213+
214+
export type ContentConfig = typeof import("../../src/content/config.js");
215+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
# First file: Toggle "enabled" between true and false
4+
OFOSFILE="./.vscode/ofos.json"
5+
if [ -f "$OFOSFILE" ]; then
6+
sed -i.bak 's/"enabled": true/"enabled": false/' "$OFOSFILE"
7+
rm -f "${OFOSFILE}.bak" # Remove backup
8+
else
9+
echo "File not found: $OFOSFILE"
10+
fi
11+
12+
# Second file: Change "runOn": "folderOpen" to "runOn": "default"
13+
TASKSFILE="./.vscode/tasks.json"
14+
if [ -f "$TASKSFILE" ]; then
15+
sed -i.bak 's/"runOn": "folderOpen"/"runOn": "default"/' "$TASKSFILE"
16+
rm -f "${TASKSFILE}.bak" # Remove backup
17+
else
18+
echo "File not found: $TASKSFILE"
19+
fi
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# Process YML_ variables
4+
env | grep '^YML_' | while IFS='=' read -r name value; do
5+
new_name=${name#YML_}
6+
export $new_name=\"$value\"
7+
done
8+
9+
# Write VONAGE_ variables to .env
10+
env | grep -o '^VONAGE_[^=]*' | while read varname; do
11+
echo "$varname=${!varname}" >> .env
12+
done
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"enabled": true,
3+
"startupfiles": [
4+
"send-sms.js"
5+
]
6+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"files.exclude": {
3+
"**/.DS_Store": true,
4+
"setup.json": true,
5+
"vcr.yml": true,
6+
},
7+
"vs-browser.url": "https://neru-febe6726-messages-api-sms-0-1.euw1.runtime.vonage.cloud",
8+
"vs-browser.reload.onSave": false,
9+
"workbench.startupEditor": "none"
10+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "OpenBrowser",
6+
"command": "${input:openBrowser}",
7+
"presentation": {
8+
"reveal": "never",
9+
"close": true
10+
}
11+
},
12+
{
13+
"label": "OpenTerminal",
14+
"command": "${input:openNewTerminal}",
15+
"presentation": {
16+
"reveal": "never",
17+
"close": true
18+
}
19+
},
20+
{
21+
"label": "ExportEnv",
22+
"type": "shell",
23+
"command": "chmod +x ./.vscode/envs.sh; ./.vscode/envs.sh",
24+
"presentation": {
25+
"reveal": "never",
26+
"close": true
27+
}
28+
},
29+
{
30+
"label": "CleanUp",
31+
"type": "shell",
32+
"command": "chmod +x ./.vscode/cleanup.sh; ./.vscode/cleanup.sh",
33+
"presentation": {
34+
"reveal": "never",
35+
"close": true
36+
}
37+
},
38+
{
39+
"label": "Run",
40+
"dependsOn": [
41+
"ExportEnv",
42+
"OpenBroswer",
43+
"OpenTerminal",
44+
"CleanUp"
45+
],
46+
"dependsOrder": "sequence",
47+
"runOptions": {
48+
"runOn": "folderOpen"
49+
}
50+
}
51+
],
52+
"inputs": [
53+
{
54+
"id": "openBrowser",
55+
"type": "command",
56+
"command": "vs-browser.start"
57+
},
58+
{
59+
"id": "openNewTerminal",
60+
"type": "command",
61+
"command": "workbench.action.terminal.new"
62+
}
63+
]
64+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
URL=$1
4+
CONFIG_FILE="tutorial-config.json"
5+
6+
# Ensure URL is passed as an argument
7+
if [ -z "$1" ]; then
8+
echo "Error: URL must be provided as a parameter. Aborting."
9+
exit 1
10+
fi
11+
12+
# Check if CONFIG_FILE exists
13+
if [ ! -f "$CONFIG_FILE" ]; then
14+
echo "Error: Configuration file $CONFIG_FILE not found. Aborting."
15+
exit 1
16+
fi
17+
18+
# Read JSON configuration
19+
SLUG=$(jq -r '.slug' "$CONFIG_FILE")
20+
VERSION=$(jq -r '.version' "$CONFIG_FILE")
21+
FILES=$(jq -r '.files[]' "$CONFIG_FILE")
22+
OPEN_FILE=$(jq -r '.openFile' "$CONFIG_FILE")
23+
24+
# Create files from the "files" array
25+
for FILE in $FILES; do
26+
if [ ! -f "$FILE" ]; then
27+
touch "$FILE"
28+
echo "Created file: $FILE"
29+
else
30+
echo "File already exists: $FILE"
31+
fi
32+
done
33+
34+
# Update settings.json using a temporary file
35+
SETTINGS_FILE=".vscode/settings.json"
36+
if [ -f "$SETTINGS_FILE" ]; then
37+
TEMP_FILE=$(mktemp)
38+
sed "s|\"vs-browser.url\": \".*\"|\"vs-browser.url\": \"$URL\"|" "$SETTINGS_FILE" > "$TEMP_FILE" && mv "$TEMP_FILE" "$SETTINGS_FILE"
39+
echo "Updated $SETTINGS_FILE with URL: $URL"
40+
else
41+
echo "$SETTINGS_FILE not found."
42+
fi
43+
44+
# Update ofos.json using a temporary file
45+
OFOS_FILE=".vscode/ofos.json"
46+
if [ -f "$OFOS_FILE" ]; then
47+
TEMP_FILE=$(mktemp)
48+
sed "s|<FILE>|$OPEN_FILE|" "$OFOS_FILE" > "$TEMP_FILE" && mv "$TEMP_FILE" "$OFOS_FILE"
49+
echo "Updated $OFOS_FILE with openFile: $OPEN_FILE"
50+
else
51+
echo "$OFOS_FILE not found."
52+
fi

tutorials/messages_api-sms/ws/send-sms.js

Whitespace-only changes.

0 commit comments

Comments
 (0)