@contractspec/example.calendar-google 1.57.0
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/.turbo/turbo-build$colon$bundle.log +33 -0
- package/.turbo/turbo-build.log +34 -0
- package/CHANGELOG.md +32 -0
- package/LICENSE +21 -0
- package/README.md +33 -0
- package/dist/docs/calendar-google.docblock.d.ts +1 -0
- package/dist/docs/calendar-google.docblock.js +49 -0
- package/dist/docs/calendar-google.docblock.js.map +1 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +1 -0
- package/dist/example.d.ts +7 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +44 -0
- package/dist/example.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/run.d.ts +1 -0
- package/dist/run.js +12 -0
- package/dist/run.js.map +1 -0
- package/dist/sync.d.ts +14 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +92 -0
- package/dist/sync.js.map +1 -0
- package/package.json +60 -0
- package/src/docs/calendar-google.docblock.ts +47 -0
- package/src/docs/index.ts +1 -0
- package/src/example.ts +32 -0
- package/src/index.ts +3 -0
- package/src/run.ts +10 -0
- package/src/sync.ts +104 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.js +6 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
$ tsdown
|
|
2
|
+
[34mℹ[39m tsdown [2mv0.20.3[22m powered by rolldown [2mv1.0.0-rc.3[22m
|
|
3
|
+
[34mℹ[39m config file: [4m/home/runner/work/contractspec/contractspec/packages/examples/calendar-google/tsdown.config.js[24m
|
|
4
|
+
[34mℹ[39m entry: [34msrc/example.ts, src/index.ts, src/run.ts, src/sync.ts, src/docs/calendar-google.docblock.ts, src/docs/index.ts[39m
|
|
5
|
+
[34mℹ[39m target: [34mesnext[39m
|
|
6
|
+
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
7
|
+
[34mℹ[39m Build start
|
|
8
|
+
[34mℹ[39m Cleaning 19 files
|
|
9
|
+
[34mℹ[39m [2mdist/[22m[1msync.js[22m [2m2.97 kB[22m [2m│ gzip: 1.25 kB[22m
|
|
10
|
+
[34mℹ[39m [2mdist/[22m[1mdocs/calendar-google.docblock.js[22m [2m1.62 kB[22m [2m│ gzip: 0.80 kB[22m
|
|
11
|
+
[34mℹ[39m [2mdist/[22m[1mexample.js[22m [2m0.96 kB[22m [2m│ gzip: 0.49 kB[22m
|
|
12
|
+
[34mℹ[39m [2mdist/[22m[1mrun.js[22m [2m0.28 kB[22m [2m│ gzip: 0.22 kB[22m
|
|
13
|
+
[34mℹ[39m [2mdist/[22m[1mindex.js[22m [2m0.28 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
14
|
+
[34mℹ[39m [2mdist/[22m[1mdocs/index.js[22m [2m0.04 kB[22m [2m│ gzip: 0.06 kB[22m
|
|
15
|
+
[34mℹ[39m [2mdist/[22msync.js.map [2m5.05 kB[22m [2m│ gzip: 1.98 kB[22m
|
|
16
|
+
[34mℹ[39m [2mdist/[22mdocs/calendar-google.docblock.js.map [2m2.13 kB[22m [2m│ gzip: 0.98 kB[22m
|
|
17
|
+
[34mℹ[39m [2mdist/[22mexample.js.map [2m1.43 kB[22m [2m│ gzip: 0.69 kB[22m
|
|
18
|
+
[34mℹ[39m [2mdist/[22mrun.js.map [2m0.49 kB[22m [2m│ gzip: 0.33 kB[22m
|
|
19
|
+
[34mℹ[39m [2mdist/[22msync.d.ts.map [2m0.34 kB[22m [2m│ gzip: 0.21 kB[22m
|
|
20
|
+
[34mℹ[39m [2mdist/[22mexample.d.ts.map [2m0.13 kB[22m [2m│ gzip: 0.13 kB[22m
|
|
21
|
+
[34mℹ[39m [2mdist/[22m[32m[1msync.d.ts[22m[39m [2m0.78 kB[22m [2m│ gzip: 0.33 kB[22m
|
|
22
|
+
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m0.29 kB[22m [2m│ gzip: 0.15 kB[22m
|
|
23
|
+
[34mℹ[39m [2mdist/[22m[32m[1mexample.d.ts[22m[39m [2m0.25 kB[22m [2m│ gzip: 0.17 kB[22m
|
|
24
|
+
[34mℹ[39m [2mdist/[22m[32m[1mdocs/calendar-google.docblock.d.ts[22m[39m [2m0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
25
|
+
[34mℹ[39m [2mdist/[22m[32m[1mdocs/index.d.ts[22m[39m [2m0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
26
|
+
[34mℹ[39m [2mdist/[22m[32m[1mrun.d.ts[22m[39m [2m0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
27
|
+
[34mℹ[39m 18 files, total: 17.06 kB
|
|
28
|
+
[33m[PLUGIN_TIMINGS] Warning:[0m Your build spent significant time in plugins. Here is a breakdown:
|
|
29
|
+
- rolldown-plugin-dts:generate (60%)
|
|
30
|
+
- tsdown:external (40%)
|
|
31
|
+
See https://rolldown.rs/options/checks#plugintimings for more details.
|
|
32
|
+
|
|
33
|
+
[32m✔[39m Build complete in [32m46144ms[39m
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
$ bun build:types && bun build:bundle
|
|
2
|
+
$ tsc --noEmit
|
|
3
|
+
$ tsdown
|
|
4
|
+
[34mℹ[39m tsdown [2mv0.20.3[22m powered by rolldown [2mv1.0.0-rc.3[22m
|
|
5
|
+
[34mℹ[39m config file: [4m/home/runner/work/contractspec/contractspec/packages/examples/calendar-google/tsdown.config.js[24m
|
|
6
|
+
[34mℹ[39m entry: [34msrc/example.ts, src/index.ts, src/run.ts, src/sync.ts, src/docs/calendar-google.docblock.ts, src/docs/index.ts[39m
|
|
7
|
+
[34mℹ[39m target: [34mesnext[39m
|
|
8
|
+
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
9
|
+
[34mℹ[39m Build start
|
|
10
|
+
[34mℹ[39m [2mdist/[22m[1msync.js[22m [2m2.97 kB[22m [2m│ gzip: 1.25 kB[22m
|
|
11
|
+
[34mℹ[39m [2mdist/[22m[1mdocs/calendar-google.docblock.js[22m [2m1.62 kB[22m [2m│ gzip: 0.80 kB[22m
|
|
12
|
+
[34mℹ[39m [2mdist/[22m[1mexample.js[22m [2m0.96 kB[22m [2m│ gzip: 0.49 kB[22m
|
|
13
|
+
[34mℹ[39m [2mdist/[22m[1mrun.js[22m [2m0.28 kB[22m [2m│ gzip: 0.22 kB[22m
|
|
14
|
+
[34mℹ[39m [2mdist/[22m[1mindex.js[22m [2m0.28 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
15
|
+
[34mℹ[39m [2mdist/[22m[1mdocs/index.js[22m [2m0.04 kB[22m [2m│ gzip: 0.06 kB[22m
|
|
16
|
+
[34mℹ[39m [2mdist/[22msync.js.map [2m5.05 kB[22m [2m│ gzip: 1.98 kB[22m
|
|
17
|
+
[34mℹ[39m [2mdist/[22mdocs/calendar-google.docblock.js.map [2m2.13 kB[22m [2m│ gzip: 0.98 kB[22m
|
|
18
|
+
[34mℹ[39m [2mdist/[22mexample.js.map [2m1.43 kB[22m [2m│ gzip: 0.69 kB[22m
|
|
19
|
+
[34mℹ[39m [2mdist/[22mrun.js.map [2m0.49 kB[22m [2m│ gzip: 0.33 kB[22m
|
|
20
|
+
[34mℹ[39m [2mdist/[22msync.d.ts.map [2m0.34 kB[22m [2m│ gzip: 0.21 kB[22m
|
|
21
|
+
[34mℹ[39m [2mdist/[22mexample.d.ts.map [2m0.13 kB[22m [2m│ gzip: 0.13 kB[22m
|
|
22
|
+
[34mℹ[39m [2mdist/[22m[32m[1msync.d.ts[22m[39m [2m0.78 kB[22m [2m│ gzip: 0.33 kB[22m
|
|
23
|
+
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m0.29 kB[22m [2m│ gzip: 0.15 kB[22m
|
|
24
|
+
[34mℹ[39m [2mdist/[22m[32m[1mexample.d.ts[22m[39m [2m0.25 kB[22m [2m│ gzip: 0.17 kB[22m
|
|
25
|
+
[34mℹ[39m [2mdist/[22m[32m[1mdocs/calendar-google.docblock.d.ts[22m[39m [2m0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
26
|
+
[34mℹ[39m [2mdist/[22m[32m[1mdocs/index.d.ts[22m[39m [2m0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
27
|
+
[34mℹ[39m [2mdist/[22m[32m[1mrun.d.ts[22m[39m [2m0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
28
|
+
[34mℹ[39m 18 files, total: 17.06 kB
|
|
29
|
+
[33m[PLUGIN_TIMINGS] Warning:[0m Your build spent significant time in plugins. Here is a breakdown:
|
|
30
|
+
- tsdown:external (50%)
|
|
31
|
+
- rolldown-plugin-dts:generate (50%)
|
|
32
|
+
See https://rolldown.rs/options/checks#plugintimings for more details.
|
|
33
|
+
|
|
34
|
+
[32m✔[39m Build complete in [32m90538ms[39m
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @contractspec/example.calendar-google
|
|
2
|
+
|
|
3
|
+
## 1.57.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5f660cd: Add Google Calendar and Gmail integration examples.
|
|
8
|
+
- 4651e06: Add Supabase and voice provider integrations with new runnable examples, and expose these providers across contracts, workspace tooling, and provider factory wiring.
|
|
9
|
+
- ad9d10a: feat: improve posthog integration
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [8ecf3c1]
|
|
14
|
+
- Updated dependencies [47c48c2]
|
|
15
|
+
- Updated dependencies [a119963]
|
|
16
|
+
- Updated dependencies [4651e06]
|
|
17
|
+
- Updated dependencies [ad9d10a]
|
|
18
|
+
- Updated dependencies [11a5a05]
|
|
19
|
+
- @contractspec/lib.contracts@1.57.0
|
|
20
|
+
- @contractspec/integration.providers-impls@1.57.0
|
|
21
|
+
|
|
22
|
+
## 1.56.1
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- Initial Google Calendar integration example.
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
- @contractspec/integration.providers-impls@1.56.1
|
|
32
|
+
- @contractspec/lib.contracts@1.56.1
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Chaman Ventures, SASU
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
### Integration Example - Google Calendar
|
|
2
|
+
|
|
3
|
+
Website: https://contractspec.io/
|
|
4
|
+
|
|
5
|
+
This example shows how to list upcoming events and create a new event using the Google Calendar provider.
|
|
6
|
+
|
|
7
|
+
Files included:
|
|
8
|
+
|
|
9
|
+
- `example.ts` - example metadata for the catalog.
|
|
10
|
+
- `sync.ts` - helper to build sample events and sync them to Google Calendar.
|
|
11
|
+
- `docs/calendar-google.docblock.ts` - documentation blocks for MCP/docs.
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
export CONTRACTSPEC_CALENDAR_DRY_RUN="true" # set to false to create real events
|
|
17
|
+
export GOOGLE_CLIENT_ID="your_client_id"
|
|
18
|
+
export GOOGLE_CLIENT_SECRET="your_client_secret"
|
|
19
|
+
export GOOGLE_REFRESH_TOKEN="your_refresh_token"
|
|
20
|
+
export GOOGLE_REDIRECT_URI="https://developers.google.com/oauthplayground" # optional
|
|
21
|
+
export GOOGLE_CALENDAR_ID="primary" # optional
|
|
22
|
+
|
|
23
|
+
bun tsx packages/examples/calendar-google/src/run.ts
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Refresh token notes:
|
|
27
|
+
|
|
28
|
+
1. Open https://developers.google.com/oauthplayground
|
|
29
|
+
2. Click the gear icon and enable "Use your own OAuth credentials"
|
|
30
|
+
3. Enter GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET
|
|
31
|
+
4. Authorize scope https://www.googleapis.com/auth/calendar
|
|
32
|
+
5. Exchange for tokens and copy the refresh token
|
|
33
|
+
6. Export GOOGLE_REFRESH_TOKEN and rerun the script
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
|
|
2
|
+
|
|
3
|
+
//#region src/docs/calendar-google.docblock.ts
|
|
4
|
+
registerDocBlocks([{
|
|
5
|
+
id: "docs.examples.calendar-google",
|
|
6
|
+
title: "Google Calendar (example)",
|
|
7
|
+
summary: "List upcoming events and create a new event via Google Calendar.",
|
|
8
|
+
kind: "reference",
|
|
9
|
+
visibility: "public",
|
|
10
|
+
route: "/docs/examples/calendar-google",
|
|
11
|
+
tags: [
|
|
12
|
+
"calendar",
|
|
13
|
+
"google-calendar",
|
|
14
|
+
"example"
|
|
15
|
+
],
|
|
16
|
+
body: `## What this example shows
|
|
17
|
+
- Create a Google OAuth client from env vars.
|
|
18
|
+
- List upcoming events with time bounds.
|
|
19
|
+
- Create a new event with attendees and reminders.
|
|
20
|
+
|
|
21
|
+
## Guardrails
|
|
22
|
+
- Keep refresh tokens in secrets.
|
|
23
|
+
- Use dry-run when validating payloads.
|
|
24
|
+
- Limit maxResults for quick previews.`
|
|
25
|
+
}, {
|
|
26
|
+
id: "docs.examples.calendar-google.usage",
|
|
27
|
+
title: "Google Calendar - Usage",
|
|
28
|
+
summary: "How to run the calendar sync with env-driven settings.",
|
|
29
|
+
kind: "usage",
|
|
30
|
+
visibility: "public",
|
|
31
|
+
route: "/docs/examples/calendar-google/usage",
|
|
32
|
+
tags: ["calendar", "usage"],
|
|
33
|
+
body: `## Usage
|
|
34
|
+
- Set GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_REFRESH_TOKEN.
|
|
35
|
+
- Optionally set GOOGLE_CALENDAR_ID (defaults to primary).
|
|
36
|
+
- Run the sync script to create a sample event.
|
|
37
|
+
|
|
38
|
+
## Refresh token
|
|
39
|
+
- Open https://developers.google.com/oauthplayground.
|
|
40
|
+
- Enable "Use your own OAuth credentials" and enter client ID/secret.
|
|
41
|
+
- Authorize https://www.googleapis.com/auth/calendar and exchange tokens.
|
|
42
|
+
- Copy the refresh token into GOOGLE_REFRESH_TOKEN.
|
|
43
|
+
|
|
44
|
+
## Example
|
|
45
|
+
- Call runCalendarSyncFromEnv() from run.ts to execute the flow.`
|
|
46
|
+
}]);
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
//# sourceMappingURL=calendar-google.docblock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-google.docblock.js","names":[],"sources":["../../src/docs/calendar-google.docblock.ts"],"sourcesContent":["import type { DocBlock } from '@contractspec/lib.contracts/docs';\nimport { registerDocBlocks } from '@contractspec/lib.contracts/docs';\n\nconst blocks: DocBlock[] = [\n {\n id: 'docs.examples.calendar-google',\n title: 'Google Calendar (example)',\n summary: 'List upcoming events and create a new event via Google Calendar.',\n kind: 'reference',\n visibility: 'public',\n route: '/docs/examples/calendar-google',\n tags: ['calendar', 'google-calendar', 'example'],\n body: `## What this example shows\n- Create a Google OAuth client from env vars.\n- List upcoming events with time bounds.\n- Create a new event with attendees and reminders.\n\n## Guardrails\n- Keep refresh tokens in secrets.\n- Use dry-run when validating payloads.\n- Limit maxResults for quick previews.`,\n },\n {\n id: 'docs.examples.calendar-google.usage',\n title: 'Google Calendar - Usage',\n summary: 'How to run the calendar sync with env-driven settings.',\n kind: 'usage',\n visibility: 'public',\n route: '/docs/examples/calendar-google/usage',\n tags: ['calendar', 'usage'],\n body: `## Usage\n- Set GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_REFRESH_TOKEN.\n- Optionally set GOOGLE_CALENDAR_ID (defaults to primary).\n- Run the sync script to create a sample event.\n\n## Refresh token\n- Open https://developers.google.com/oauthplayground.\n- Enable \"Use your own OAuth credentials\" and enter client ID/secret.\n- Authorize https://www.googleapis.com/auth/calendar and exchange tokens.\n- Copy the refresh token into GOOGLE_REFRESH_TOKEN.\n\n## Example\n- Call runCalendarSyncFromEnv() from run.ts to execute the flow.`,\n },\n];\n\nregisterDocBlocks(blocks);\n"],"mappings":";;;AA8CA,kBA3C2B,CACzB;CACE,IAAI;CACJ,OAAO;CACP,SAAS;CACT,MAAM;CACN,YAAY;CACZ,OAAO;CACP,MAAM;EAAC;EAAY;EAAmB;EAAU;CAChD,MAAM;;;;;;;;;CASP,EACD;CACE,IAAI;CACJ,OAAO;CACP,SAAS;CACT,MAAM;CACN,YAAY;CACZ,OAAO;CACP,MAAM,CAAC,YAAY,QAAQ;CAC3B,MAAM;;;;;;;;;;;;;CAaP,CACF,CAEwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./calendar-google.docblock.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.d.ts","names":[],"sources":["../src/example.ts"],"mappings":";;;cAEM,OAAA,EA2BJ,4BAAA,CA3BW,WAAA"}
|
package/dist/example.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineExample } from "@contractspec/lib.contracts";
|
|
2
|
+
|
|
3
|
+
//#region src/example.ts
|
|
4
|
+
const example = defineExample({
|
|
5
|
+
meta: {
|
|
6
|
+
key: "calendar-google",
|
|
7
|
+
version: "1.0.0",
|
|
8
|
+
title: "Google Calendar",
|
|
9
|
+
description: "List upcoming events and create a new event using the Google Calendar provider.",
|
|
10
|
+
kind: "integration",
|
|
11
|
+
visibility: "public",
|
|
12
|
+
stability: "experimental",
|
|
13
|
+
owners: ["@platform.integrations"],
|
|
14
|
+
tags: [
|
|
15
|
+
"calendar",
|
|
16
|
+
"google-calendar",
|
|
17
|
+
"integrations"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
docs: {
|
|
21
|
+
rootDocId: "docs.examples.calendar-google",
|
|
22
|
+
usageDocId: "docs.examples.calendar-google.usage"
|
|
23
|
+
},
|
|
24
|
+
entrypoints: {
|
|
25
|
+
packageName: "@contractspec/example.calendar-google",
|
|
26
|
+
docs: "./docs"
|
|
27
|
+
},
|
|
28
|
+
surfaces: {
|
|
29
|
+
templates: true,
|
|
30
|
+
sandbox: {
|
|
31
|
+
enabled: true,
|
|
32
|
+
modes: ["markdown", "specs"]
|
|
33
|
+
},
|
|
34
|
+
studio: {
|
|
35
|
+
enabled: true,
|
|
36
|
+
installable: true
|
|
37
|
+
},
|
|
38
|
+
mcp: { enabled: true }
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { example as default };
|
|
44
|
+
//# sourceMappingURL=example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.js","names":[],"sources":["../src/example.ts"],"sourcesContent":["import { defineExample } from '@contractspec/lib.contracts';\n\nconst example = defineExample({\n meta: {\n key: 'calendar-google',\n version: '1.0.0',\n title: 'Google Calendar',\n description:\n 'List upcoming events and create a new event using the Google Calendar provider.',\n kind: 'integration',\n visibility: 'public',\n stability: 'experimental',\n owners: ['@platform.integrations'],\n tags: ['calendar', 'google-calendar', 'integrations'],\n },\n docs: {\n rootDocId: 'docs.examples.calendar-google',\n usageDocId: 'docs.examples.calendar-google.usage',\n },\n entrypoints: {\n packageName: '@contractspec/example.calendar-google',\n docs: './docs',\n },\n surfaces: {\n templates: true,\n sandbox: { enabled: true, modes: ['markdown', 'specs'] },\n studio: { enabled: true, installable: true },\n mcp: { enabled: true },\n },\n});\n\nexport default example;\n"],"mappings":";;;AAEA,MAAM,UAAU,cAAc;CAC5B,MAAM;EACJ,KAAK;EACL,SAAS;EACT,OAAO;EACP,aACE;EACF,MAAM;EACN,YAAY;EACZ,WAAW;EACX,QAAQ,CAAC,yBAAyB;EAClC,MAAM;GAAC;GAAY;GAAmB;GAAe;EACtD;CACD,MAAM;EACJ,WAAW;EACX,YAAY;EACb;CACD,aAAa;EACX,aAAa;EACb,MAAM;EACP;CACD,UAAU;EACR,WAAW;EACX,SAAS;GAAE,SAAS;GAAM,OAAO,CAAC,YAAY,QAAQ;GAAE;EACxD,QAAQ;GAAE,SAAS;GAAM,aAAa;GAAM;EAC5C,KAAK,EAAE,SAAS,MAAM;EACvB;CACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import example from "./example.js";
|
|
2
|
+
import { CalendarSyncOutput, buildSampleEvent, buildUpcomingQuery, createProviderFromEnv, runCalendarSyncFromEnv } from "./sync.js";
|
|
3
|
+
export { CalendarSyncOutput, buildSampleEvent, buildUpcomingQuery, createProviderFromEnv, example, runCalendarSyncFromEnv };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import example from "./example.js";
|
|
2
|
+
import { buildSampleEvent, buildUpcomingQuery, createProviderFromEnv, runCalendarSyncFromEnv } from "./sync.js";
|
|
3
|
+
import "./docs/index.js";
|
|
4
|
+
|
|
5
|
+
export { buildSampleEvent, buildUpcomingQuery, createProviderFromEnv, example, runCalendarSyncFromEnv };
|
package/dist/run.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/run.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { runCalendarSyncFromEnv } from "./sync.js";
|
|
2
|
+
|
|
3
|
+
//#region src/run.ts
|
|
4
|
+
runCalendarSyncFromEnv().then((result) => {
|
|
5
|
+
console.log(JSON.stringify(result, null, 2));
|
|
6
|
+
}).catch((error) => {
|
|
7
|
+
console.error(error);
|
|
8
|
+
process.exitCode = 1;
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
//# sourceMappingURL=run.js.map
|
package/dist/run.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","names":[],"sources":["../src/run.ts"],"sourcesContent":["import { runCalendarSyncFromEnv } from './sync';\n\nrunCalendarSyncFromEnv()\n .then((result) => {\n console.log(JSON.stringify(result, null, 2));\n })\n .catch((error) => {\n console.error(error);\n process.exitCode = 1;\n });\n"],"mappings":";;;AAEA,wBAAwB,CACrB,MAAM,WAAW;AAChB,SAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,EAAE,CAAC;EAC5C,CACD,OAAO,UAAU;AAChB,SAAQ,MAAM,MAAM;AACpB,SAAQ,WAAW;EACnB"}
|
package/dist/sync.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CalendarEvent, CalendarEventInput, CalendarListEventsQuery, CalendarProvider } from "@contractspec/integration.providers-impls/calendar";
|
|
2
|
+
|
|
3
|
+
//#region src/sync.d.ts
|
|
4
|
+
interface CalendarSyncOutput {
|
|
5
|
+
created?: CalendarEvent | CalendarEventInput;
|
|
6
|
+
upcoming: CalendarEvent[] | CalendarEventInput[];
|
|
7
|
+
}
|
|
8
|
+
declare function runCalendarSyncFromEnv(): Promise<CalendarSyncOutput>;
|
|
9
|
+
declare function buildSampleEvent(calendarId: string): CalendarEventInput;
|
|
10
|
+
declare function buildUpcomingQuery(calendarId: string): CalendarListEventsQuery;
|
|
11
|
+
declare function createProviderFromEnv(calendarId: string): CalendarProvider;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { CalendarSyncOutput, buildSampleEvent, buildUpcomingQuery, createProviderFromEnv, runCalendarSyncFromEnv };
|
|
14
|
+
//# sourceMappingURL=sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.d.ts","names":[],"sources":["../src/sync.ts"],"mappings":";;;UASiB,kBAAA;EACf,OAAA,GAAU,aAAA,GAAgB,kBAAA;EAC1B,QAAA,EAAU,aAAA,KAAkB,kBAAA;AAAA;AAAA,iBAGR,sBAAA,CAAA,GAA0B,OAAA,CAAQ,kBAAA;AAAA,iBAgBxC,gBAAA,CAAiB,UAAA,WAAqB,kBAAA;AAAA,iBAiBtC,kBAAA,CACd,UAAA,WACC,uBAAA;AAAA,iBAWa,qBAAA,CAAsB,UAAA,WAAqB,gBAAA"}
|
package/dist/sync.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { google } from "googleapis";
|
|
2
|
+
import { GoogleCalendarProvider } from "@contractspec/integration.providers-impls/impls/google-calendar";
|
|
3
|
+
|
|
4
|
+
//#region src/sync.ts
|
|
5
|
+
async function runCalendarSyncFromEnv() {
|
|
6
|
+
const calendarId = resolveCalendarId();
|
|
7
|
+
const dryRun = process.env.CONTRACTSPEC_CALENDAR_DRY_RUN === "true";
|
|
8
|
+
const eventInput = buildSampleEvent(calendarId);
|
|
9
|
+
const listQuery = buildUpcomingQuery(calendarId);
|
|
10
|
+
if (dryRun) return {
|
|
11
|
+
created: eventInput,
|
|
12
|
+
upcoming: [eventInput]
|
|
13
|
+
};
|
|
14
|
+
const provider = createProviderFromEnv(calendarId);
|
|
15
|
+
return {
|
|
16
|
+
created: await provider.createEvent(eventInput),
|
|
17
|
+
upcoming: (await provider.listEvents(listQuery)).events
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function buildSampleEvent(calendarId) {
|
|
21
|
+
const start = /* @__PURE__ */ new Date();
|
|
22
|
+
return {
|
|
23
|
+
calendarId,
|
|
24
|
+
title: "Product sync review",
|
|
25
|
+
description: "Review onboarding friction and sync action items.",
|
|
26
|
+
location: "Zoom",
|
|
27
|
+
start,
|
|
28
|
+
end: new Date(start.getTime() + 1800 * 1e3),
|
|
29
|
+
conference: {
|
|
30
|
+
create: true,
|
|
31
|
+
type: "google_meet"
|
|
32
|
+
},
|
|
33
|
+
attendees: [{
|
|
34
|
+
email: "teammate@example.com",
|
|
35
|
+
name: "Teammate"
|
|
36
|
+
}],
|
|
37
|
+
reminders: [{
|
|
38
|
+
method: "popup",
|
|
39
|
+
minutesBeforeStart: 10
|
|
40
|
+
}],
|
|
41
|
+
metadata: { source: "contractspec-example" }
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function buildUpcomingQuery(calendarId) {
|
|
45
|
+
const now = /* @__PURE__ */ new Date();
|
|
46
|
+
return {
|
|
47
|
+
calendarId,
|
|
48
|
+
timeMin: now,
|
|
49
|
+
timeMax: new Date(now.getTime() + 10080 * 60 * 1e3),
|
|
50
|
+
maxResults: 5
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function createProviderFromEnv(calendarId) {
|
|
54
|
+
return new GoogleCalendarProvider({
|
|
55
|
+
auth: createGoogleAuthFromEnv(),
|
|
56
|
+
calendarId
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function createGoogleAuthFromEnv() {
|
|
60
|
+
const clientId = requireEnv("GOOGLE_CLIENT_ID");
|
|
61
|
+
const clientSecret = requireEnv("GOOGLE_CLIENT_SECRET");
|
|
62
|
+
const refreshToken = requireEnv("GOOGLE_REFRESH_TOKEN");
|
|
63
|
+
const redirectUri = process.env.GOOGLE_REDIRECT_URI ?? "https://developers.google.com/oauthplayground";
|
|
64
|
+
const oauth = new google.auth.OAuth2(clientId, clientSecret, redirectUri);
|
|
65
|
+
oauth.setCredentials({ refresh_token: refreshToken });
|
|
66
|
+
return oauth;
|
|
67
|
+
}
|
|
68
|
+
function resolveCalendarId() {
|
|
69
|
+
return process.env.GOOGLE_CALENDAR_ID ?? "primary";
|
|
70
|
+
}
|
|
71
|
+
function requireEnv(key) {
|
|
72
|
+
const value = process.env[key];
|
|
73
|
+
if (!value) throw new Error(buildMissingEnvMessage(key));
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
function buildMissingEnvMessage(key) {
|
|
77
|
+
if (key !== "GOOGLE_REFRESH_TOKEN") return `Missing required env var: ${key}`;
|
|
78
|
+
return [
|
|
79
|
+
`Missing required env var: ${key}`,
|
|
80
|
+
"Get a refresh token with OAuth Playground:",
|
|
81
|
+
"1) Open https://developers.google.com/oauthplayground",
|
|
82
|
+
"2) Click the gear icon and enable \"Use your own OAuth credentials\"",
|
|
83
|
+
"3) Enter GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET",
|
|
84
|
+
"4) Authorize scope https://www.googleapis.com/auth/calendar",
|
|
85
|
+
"5) Exchange for tokens and copy the refresh token",
|
|
86
|
+
"Then export GOOGLE_REFRESH_TOKEN and rerun the script."
|
|
87
|
+
].join("\n");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
export { buildSampleEvent, buildUpcomingQuery, createProviderFromEnv, runCalendarSyncFromEnv };
|
|
92
|
+
//# sourceMappingURL=sync.js.map
|
package/dist/sync.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.js","names":[],"sources":["../src/sync.ts"],"sourcesContent":["import { google } from 'googleapis';\nimport { GoogleCalendarProvider } from '@contractspec/integration.providers-impls/impls/google-calendar';\nimport type {\n CalendarEvent,\n CalendarEventInput,\n CalendarListEventsQuery,\n CalendarProvider,\n} from '@contractspec/integration.providers-impls/calendar';\n\nexport interface CalendarSyncOutput {\n created?: CalendarEvent | CalendarEventInput;\n upcoming: CalendarEvent[] | CalendarEventInput[];\n}\n\nexport async function runCalendarSyncFromEnv(): Promise<CalendarSyncOutput> {\n const calendarId = resolveCalendarId();\n const dryRun = process.env.CONTRACTSPEC_CALENDAR_DRY_RUN === 'true';\n const eventInput = buildSampleEvent(calendarId);\n const listQuery = buildUpcomingQuery(calendarId);\n\n if (dryRun) {\n return { created: eventInput, upcoming: [eventInput] };\n }\n\n const provider = createProviderFromEnv(calendarId);\n const created = await provider.createEvent(eventInput);\n const upcoming = await provider.listEvents(listQuery);\n return { created, upcoming: upcoming.events };\n}\n\nexport function buildSampleEvent(calendarId: string): CalendarEventInput {\n const start = new Date();\n const end = new Date(start.getTime() + 30 * 60 * 1000);\n return {\n calendarId,\n title: 'Product sync review',\n description: 'Review onboarding friction and sync action items.',\n location: 'Zoom',\n start,\n end,\n conference: { create: true, type: 'google_meet' },\n attendees: [{ email: 'teammate@example.com', name: 'Teammate' }],\n reminders: [{ method: 'popup', minutesBeforeStart: 10 }],\n metadata: { source: 'contractspec-example' },\n };\n}\n\nexport function buildUpcomingQuery(\n calendarId: string\n): CalendarListEventsQuery {\n const now = new Date();\n const inSevenDays = new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000);\n return {\n calendarId,\n timeMin: now,\n timeMax: inSevenDays,\n maxResults: 5,\n };\n}\n\nexport function createProviderFromEnv(calendarId: string): CalendarProvider {\n const auth = createGoogleAuthFromEnv();\n return new GoogleCalendarProvider({ auth, calendarId });\n}\n\nfunction createGoogleAuthFromEnv() {\n const clientId = requireEnv('GOOGLE_CLIENT_ID');\n const clientSecret = requireEnv('GOOGLE_CLIENT_SECRET');\n const refreshToken = requireEnv('GOOGLE_REFRESH_TOKEN');\n const redirectUri =\n process.env.GOOGLE_REDIRECT_URI ??\n 'https://developers.google.com/oauthplayground';\n const oauth = new google.auth.OAuth2(clientId, clientSecret, redirectUri);\n oauth.setCredentials({ refresh_token: refreshToken });\n return oauth;\n}\n\nfunction resolveCalendarId(): string {\n return process.env.GOOGLE_CALENDAR_ID ?? 'primary';\n}\n\nfunction requireEnv(key: string): string {\n const value = process.env[key];\n if (!value) {\n throw new Error(buildMissingEnvMessage(key));\n }\n return value;\n}\n\nfunction buildMissingEnvMessage(key: string): string {\n if (key !== 'GOOGLE_REFRESH_TOKEN') {\n return `Missing required env var: ${key}`;\n }\n return [\n `Missing required env var: ${key}`,\n 'Get a refresh token with OAuth Playground:',\n '1) Open https://developers.google.com/oauthplayground',\n '2) Click the gear icon and enable \"Use your own OAuth credentials\"',\n '3) Enter GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET',\n '4) Authorize scope https://www.googleapis.com/auth/calendar',\n '5) Exchange for tokens and copy the refresh token',\n 'Then export GOOGLE_REFRESH_TOKEN and rerun the script.',\n ].join('\\n');\n}\n"],"mappings":";;;;AAcA,eAAsB,yBAAsD;CAC1E,MAAM,aAAa,mBAAmB;CACtC,MAAM,SAAS,QAAQ,IAAI,kCAAkC;CAC7D,MAAM,aAAa,iBAAiB,WAAW;CAC/C,MAAM,YAAY,mBAAmB,WAAW;AAEhD,KAAI,OACF,QAAO;EAAE,SAAS;EAAY,UAAU,CAAC,WAAW;EAAE;CAGxD,MAAM,WAAW,sBAAsB,WAAW;AAGlD,QAAO;EAAE,SAFO,MAAM,SAAS,YAAY,WAAW;EAEpC,WADD,MAAM,SAAS,WAAW,UAAU,EAChB;EAAQ;;AAG/C,SAAgB,iBAAiB,YAAwC;CACvE,MAAM,wBAAQ,IAAI,MAAM;AAExB,QAAO;EACL;EACA,OAAO;EACP,aAAa;EACb,UAAU;EACV;EACA,KAPU,IAAI,KAAK,MAAM,SAAS,GAAG,OAAU,IAAK;EAQpD,YAAY;GAAE,QAAQ;GAAM,MAAM;GAAe;EACjD,WAAW,CAAC;GAAE,OAAO;GAAwB,MAAM;GAAY,CAAC;EAChE,WAAW,CAAC;GAAE,QAAQ;GAAS,oBAAoB;GAAI,CAAC;EACxD,UAAU,EAAE,QAAQ,wBAAwB;EAC7C;;AAGH,SAAgB,mBACd,YACyB;CACzB,MAAM,sBAAM,IAAI,MAAM;AAEtB,QAAO;EACL;EACA,SAAS;EACT,SAJkB,IAAI,KAAK,IAAI,SAAS,GAAG,QAAc,KAAK,IAAK;EAKnE,YAAY;EACb;;AAGH,SAAgB,sBAAsB,YAAsC;AAE1E,QAAO,IAAI,uBAAuB;EAAE,MADvB,yBAAyB;EACI;EAAY,CAAC;;AAGzD,SAAS,0BAA0B;CACjC,MAAM,WAAW,WAAW,mBAAmB;CAC/C,MAAM,eAAe,WAAW,uBAAuB;CACvD,MAAM,eAAe,WAAW,uBAAuB;CACvD,MAAM,cACJ,QAAQ,IAAI,uBACZ;CACF,MAAM,QAAQ,IAAI,OAAO,KAAK,OAAO,UAAU,cAAc,YAAY;AACzE,OAAM,eAAe,EAAE,eAAe,cAAc,CAAC;AACrD,QAAO;;AAGT,SAAS,oBAA4B;AACnC,QAAO,QAAQ,IAAI,sBAAsB;;AAG3C,SAAS,WAAW,KAAqB;CACvC,MAAM,QAAQ,QAAQ,IAAI;AAC1B,KAAI,CAAC,MACH,OAAM,IAAI,MAAM,uBAAuB,IAAI,CAAC;AAE9C,QAAO;;AAGT,SAAS,uBAAuB,KAAqB;AACnD,KAAI,QAAQ,uBACV,QAAO,6BAA6B;AAEtC,QAAO;EACL,6BAA6B;EAC7B;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,KAAK"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contractspec/example.calendar-google",
|
|
3
|
+
"version": "1.57.0",
|
|
4
|
+
"description": "Google Calendar integration example: list and create events.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./docs": "./dist/docs/index.js",
|
|
10
|
+
"./docs/calendar-google.docblock": "./dist/docs/calendar-google.docblock.js",
|
|
11
|
+
"./example": "./dist/example.js",
|
|
12
|
+
"./run": "./dist/run.js",
|
|
13
|
+
"./sync": "./dist/sync.js",
|
|
14
|
+
"./*": "./*"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
18
|
+
"publish:pkg:canary": "bun publish:pkg --tag canary",
|
|
19
|
+
"build": "bun build:types && bun build:bundle",
|
|
20
|
+
"build:bundle": "tsdown",
|
|
21
|
+
"build:types": "tsc --noEmit",
|
|
22
|
+
"dev": "bun build:bundle --watch",
|
|
23
|
+
"clean": "rimraf dist .turbo",
|
|
24
|
+
"lint": "bun lint:fix",
|
|
25
|
+
"lint:fix": "eslint src --fix",
|
|
26
|
+
"lint:check": "eslint src",
|
|
27
|
+
"test": "bun test"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@contractspec/integration.providers-impls": "1.57.0",
|
|
31
|
+
"@contractspec/lib.contracts": "1.57.0",
|
|
32
|
+
"googleapis": "^171.4.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@contractspec/tool.tsdown": "1.57.0",
|
|
36
|
+
"@contractspec/tool.typescript": "1.57.0",
|
|
37
|
+
"tsdown": "^0.20.3",
|
|
38
|
+
"typescript": "^5.9.3"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public",
|
|
42
|
+
"exports": {
|
|
43
|
+
".": "./dist/index.js",
|
|
44
|
+
"./docs": "./dist/docs/index.js",
|
|
45
|
+
"./docs/calendar-google.docblock": "./dist/docs/calendar-google.docblock.js",
|
|
46
|
+
"./example": "./dist/example.js",
|
|
47
|
+
"./run": "./dist/run.js",
|
|
48
|
+
"./sync": "./dist/sync.js",
|
|
49
|
+
"./*": "./*"
|
|
50
|
+
},
|
|
51
|
+
"registry": "https://registry.npmjs.org/"
|
|
52
|
+
},
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "https://github.com/lssm-tech/contractspec.git",
|
|
57
|
+
"directory": "packages/examples/calendar-google"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://contractspec.io"
|
|
60
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { DocBlock } from '@contractspec/lib.contracts/docs';
|
|
2
|
+
import { registerDocBlocks } from '@contractspec/lib.contracts/docs';
|
|
3
|
+
|
|
4
|
+
const blocks: DocBlock[] = [
|
|
5
|
+
{
|
|
6
|
+
id: 'docs.examples.calendar-google',
|
|
7
|
+
title: 'Google Calendar (example)',
|
|
8
|
+
summary: 'List upcoming events and create a new event via Google Calendar.',
|
|
9
|
+
kind: 'reference',
|
|
10
|
+
visibility: 'public',
|
|
11
|
+
route: '/docs/examples/calendar-google',
|
|
12
|
+
tags: ['calendar', 'google-calendar', 'example'],
|
|
13
|
+
body: `## What this example shows
|
|
14
|
+
- Create a Google OAuth client from env vars.
|
|
15
|
+
- List upcoming events with time bounds.
|
|
16
|
+
- Create a new event with attendees and reminders.
|
|
17
|
+
|
|
18
|
+
## Guardrails
|
|
19
|
+
- Keep refresh tokens in secrets.
|
|
20
|
+
- Use dry-run when validating payloads.
|
|
21
|
+
- Limit maxResults for quick previews.`,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'docs.examples.calendar-google.usage',
|
|
25
|
+
title: 'Google Calendar - Usage',
|
|
26
|
+
summary: 'How to run the calendar sync with env-driven settings.',
|
|
27
|
+
kind: 'usage',
|
|
28
|
+
visibility: 'public',
|
|
29
|
+
route: '/docs/examples/calendar-google/usage',
|
|
30
|
+
tags: ['calendar', 'usage'],
|
|
31
|
+
body: `## Usage
|
|
32
|
+
- Set GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_REFRESH_TOKEN.
|
|
33
|
+
- Optionally set GOOGLE_CALENDAR_ID (defaults to primary).
|
|
34
|
+
- Run the sync script to create a sample event.
|
|
35
|
+
|
|
36
|
+
## Refresh token
|
|
37
|
+
- Open https://developers.google.com/oauthplayground.
|
|
38
|
+
- Enable "Use your own OAuth credentials" and enter client ID/secret.
|
|
39
|
+
- Authorize https://www.googleapis.com/auth/calendar and exchange tokens.
|
|
40
|
+
- Copy the refresh token into GOOGLE_REFRESH_TOKEN.
|
|
41
|
+
|
|
42
|
+
## Example
|
|
43
|
+
- Call runCalendarSyncFromEnv() from run.ts to execute the flow.`,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
registerDocBlocks(blocks);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './calendar-google.docblock';
|
package/src/example.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineExample } from '@contractspec/lib.contracts';
|
|
2
|
+
|
|
3
|
+
const example = defineExample({
|
|
4
|
+
meta: {
|
|
5
|
+
key: 'calendar-google',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
title: 'Google Calendar',
|
|
8
|
+
description:
|
|
9
|
+
'List upcoming events and create a new event using the Google Calendar provider.',
|
|
10
|
+
kind: 'integration',
|
|
11
|
+
visibility: 'public',
|
|
12
|
+
stability: 'experimental',
|
|
13
|
+
owners: ['@platform.integrations'],
|
|
14
|
+
tags: ['calendar', 'google-calendar', 'integrations'],
|
|
15
|
+
},
|
|
16
|
+
docs: {
|
|
17
|
+
rootDocId: 'docs.examples.calendar-google',
|
|
18
|
+
usageDocId: 'docs.examples.calendar-google.usage',
|
|
19
|
+
},
|
|
20
|
+
entrypoints: {
|
|
21
|
+
packageName: '@contractspec/example.calendar-google',
|
|
22
|
+
docs: './docs',
|
|
23
|
+
},
|
|
24
|
+
surfaces: {
|
|
25
|
+
templates: true,
|
|
26
|
+
sandbox: { enabled: true, modes: ['markdown', 'specs'] },
|
|
27
|
+
studio: { enabled: true, installable: true },
|
|
28
|
+
mcp: { enabled: true },
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export default example;
|
package/src/index.ts
ADDED