@contractspec/example.calendar-google 1.57.0 → 1.58.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.
Files changed (41) hide show
  1. package/.turbo/turbo-build.log +34 -33
  2. package/.turbo/turbo-prebuild.log +1 -0
  3. package/CHANGELOG.md +13 -0
  4. package/dist/browser/docs/calendar-google.docblock.js +45 -0
  5. package/dist/browser/docs/index.js +45 -0
  6. package/dist/browser/example.js +33 -0
  7. package/dist/browser/index.js +164 -0
  8. package/dist/browser/run.js +89 -0
  9. package/dist/browser/sync.js +87 -0
  10. package/dist/docs/calendar-google.docblock.d.ts +2 -1
  11. package/dist/docs/calendar-google.docblock.d.ts.map +1 -0
  12. package/dist/docs/calendar-google.docblock.js +25 -28
  13. package/dist/docs/index.d.ts +2 -1
  14. package/dist/docs/index.d.ts.map +1 -0
  15. package/dist/docs/index.js +46 -1
  16. package/dist/example.d.ts +2 -6
  17. package/dist/example.d.ts.map +1 -1
  18. package/dist/example.js +32 -42
  19. package/dist/index.d.ts +4 -3
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +164 -4
  22. package/dist/node/docs/calendar-google.docblock.js +45 -0
  23. package/dist/node/docs/index.js +45 -0
  24. package/dist/node/example.js +33 -0
  25. package/dist/node/index.js +164 -0
  26. package/dist/node/run.js +89 -0
  27. package/dist/node/sync.js +87 -0
  28. package/dist/run.d.ts +2 -1
  29. package/dist/run.d.ts.map +1 -0
  30. package/dist/run.js +86 -8
  31. package/dist/sync.d.ts +8 -12
  32. package/dist/sync.d.ts.map +1 -1
  33. package/dist/sync.js +70 -74
  34. package/package.json +69 -26
  35. package/tsdown.config.js +1 -2
  36. package/.turbo/turbo-build$colon$bundle.log +0 -33
  37. package/dist/docs/calendar-google.docblock.js.map +0 -1
  38. package/dist/example.js.map +0 -1
  39. package/dist/run.js.map +0 -1
  40. package/dist/sync.js.map +0 -1
  41. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,89 @@
1
+ // src/sync.ts
2
+ import { google } from "googleapis";
3
+ import { GoogleCalendarProvider } from "@contractspec/integration.providers-impls/impls/google-calendar";
4
+ async function runCalendarSyncFromEnv() {
5
+ const calendarId = resolveCalendarId();
6
+ const dryRun = process.env.CONTRACTSPEC_CALENDAR_DRY_RUN === "true";
7
+ const eventInput = buildSampleEvent(calendarId);
8
+ const listQuery = buildUpcomingQuery(calendarId);
9
+ if (dryRun) {
10
+ return { created: eventInput, upcoming: [eventInput] };
11
+ }
12
+ const provider = createProviderFromEnv(calendarId);
13
+ const created = await provider.createEvent(eventInput);
14
+ const upcoming = await provider.listEvents(listQuery);
15
+ return { created, upcoming: upcoming.events };
16
+ }
17
+ function buildSampleEvent(calendarId) {
18
+ const start = new Date;
19
+ const end = new Date(start.getTime() + 30 * 60 * 1000);
20
+ return {
21
+ calendarId,
22
+ title: "Product sync review",
23
+ description: "Review onboarding friction and sync action items.",
24
+ location: "Zoom",
25
+ start,
26
+ end,
27
+ conference: { create: true, type: "google_meet" },
28
+ attendees: [{ email: "teammate@example.com", name: "Teammate" }],
29
+ reminders: [{ method: "popup", minutesBeforeStart: 10 }],
30
+ metadata: { source: "contractspec-example" }
31
+ };
32
+ }
33
+ function buildUpcomingQuery(calendarId) {
34
+ const now = new Date;
35
+ const inSevenDays = new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000);
36
+ return {
37
+ calendarId,
38
+ timeMin: now,
39
+ timeMax: inSevenDays,
40
+ maxResults: 5
41
+ };
42
+ }
43
+ function createProviderFromEnv(calendarId) {
44
+ const auth = createGoogleAuthFromEnv();
45
+ return new GoogleCalendarProvider({ auth, calendarId });
46
+ }
47
+ function createGoogleAuthFromEnv() {
48
+ const clientId = requireEnv("GOOGLE_CLIENT_ID");
49
+ const clientSecret = requireEnv("GOOGLE_CLIENT_SECRET");
50
+ const refreshToken = requireEnv("GOOGLE_REFRESH_TOKEN");
51
+ const redirectUri = process.env.GOOGLE_REDIRECT_URI ?? "https://developers.google.com/oauthplayground";
52
+ const oauth = new google.auth.OAuth2(clientId, clientSecret, redirectUri);
53
+ oauth.setCredentials({ refresh_token: refreshToken });
54
+ return oauth;
55
+ }
56
+ function resolveCalendarId() {
57
+ return process.env.GOOGLE_CALENDAR_ID ?? "primary";
58
+ }
59
+ function requireEnv(key) {
60
+ const value = process.env[key];
61
+ if (!value) {
62
+ throw new Error(buildMissingEnvMessage(key));
63
+ }
64
+ return value;
65
+ }
66
+ function buildMissingEnvMessage(key) {
67
+ if (key !== "GOOGLE_REFRESH_TOKEN") {
68
+ return `Missing required env var: ${key}`;
69
+ }
70
+ return [
71
+ `Missing required env var: ${key}`,
72
+ "Get a refresh token with OAuth Playground:",
73
+ "1) Open https://developers.google.com/oauthplayground",
74
+ '2) Click the gear icon and enable "Use your own OAuth credentials"',
75
+ "3) Enter GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET",
76
+ "4) Authorize scope https://www.googleapis.com/auth/calendar",
77
+ "5) Exchange for tokens and copy the refresh token",
78
+ "Then export GOOGLE_REFRESH_TOKEN and rerun the script."
79
+ ].join(`
80
+ `);
81
+ }
82
+
83
+ // src/run.ts
84
+ runCalendarSyncFromEnv().then((result) => {
85
+ console.log(JSON.stringify(result, null, 2));
86
+ }).catch((error) => {
87
+ console.error(error);
88
+ process.exitCode = 1;
89
+ });
@@ -0,0 +1,87 @@
1
+ // src/sync.ts
2
+ import { google } from "googleapis";
3
+ import { GoogleCalendarProvider } from "@contractspec/integration.providers-impls/impls/google-calendar";
4
+ async function runCalendarSyncFromEnv() {
5
+ const calendarId = resolveCalendarId();
6
+ const dryRun = process.env.CONTRACTSPEC_CALENDAR_DRY_RUN === "true";
7
+ const eventInput = buildSampleEvent(calendarId);
8
+ const listQuery = buildUpcomingQuery(calendarId);
9
+ if (dryRun) {
10
+ return { created: eventInput, upcoming: [eventInput] };
11
+ }
12
+ const provider = createProviderFromEnv(calendarId);
13
+ const created = await provider.createEvent(eventInput);
14
+ const upcoming = await provider.listEvents(listQuery);
15
+ return { created, upcoming: upcoming.events };
16
+ }
17
+ function buildSampleEvent(calendarId) {
18
+ const start = new Date;
19
+ const end = new Date(start.getTime() + 30 * 60 * 1000);
20
+ return {
21
+ calendarId,
22
+ title: "Product sync review",
23
+ description: "Review onboarding friction and sync action items.",
24
+ location: "Zoom",
25
+ start,
26
+ end,
27
+ conference: { create: true, type: "google_meet" },
28
+ attendees: [{ email: "teammate@example.com", name: "Teammate" }],
29
+ reminders: [{ method: "popup", minutesBeforeStart: 10 }],
30
+ metadata: { source: "contractspec-example" }
31
+ };
32
+ }
33
+ function buildUpcomingQuery(calendarId) {
34
+ const now = new Date;
35
+ const inSevenDays = new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000);
36
+ return {
37
+ calendarId,
38
+ timeMin: now,
39
+ timeMax: inSevenDays,
40
+ maxResults: 5
41
+ };
42
+ }
43
+ function createProviderFromEnv(calendarId) {
44
+ const auth = createGoogleAuthFromEnv();
45
+ return new GoogleCalendarProvider({ auth, calendarId });
46
+ }
47
+ function createGoogleAuthFromEnv() {
48
+ const clientId = requireEnv("GOOGLE_CLIENT_ID");
49
+ const clientSecret = requireEnv("GOOGLE_CLIENT_SECRET");
50
+ const refreshToken = requireEnv("GOOGLE_REFRESH_TOKEN");
51
+ const redirectUri = process.env.GOOGLE_REDIRECT_URI ?? "https://developers.google.com/oauthplayground";
52
+ const oauth = new google.auth.OAuth2(clientId, clientSecret, redirectUri);
53
+ oauth.setCredentials({ refresh_token: refreshToken });
54
+ return oauth;
55
+ }
56
+ function resolveCalendarId() {
57
+ return process.env.GOOGLE_CALENDAR_ID ?? "primary";
58
+ }
59
+ function requireEnv(key) {
60
+ const value = process.env[key];
61
+ if (!value) {
62
+ throw new Error(buildMissingEnvMessage(key));
63
+ }
64
+ return value;
65
+ }
66
+ function buildMissingEnvMessage(key) {
67
+ if (key !== "GOOGLE_REFRESH_TOKEN") {
68
+ return `Missing required env var: ${key}`;
69
+ }
70
+ return [
71
+ `Missing required env var: ${key}`,
72
+ "Get a refresh token with OAuth Playground:",
73
+ "1) Open https://developers.google.com/oauthplayground",
74
+ '2) Click the gear icon and enable "Use your own OAuth credentials"',
75
+ "3) Enter GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET",
76
+ "4) Authorize scope https://www.googleapis.com/auth/calendar",
77
+ "5) Exchange for tokens and copy the refresh token",
78
+ "Then export GOOGLE_REFRESH_TOKEN and rerun the script."
79
+ ].join(`
80
+ `);
81
+ }
82
+ export {
83
+ runCalendarSyncFromEnv,
84
+ createProviderFromEnv,
85
+ buildUpcomingQuery,
86
+ buildSampleEvent
87
+ };
package/dist/run.d.ts CHANGED
@@ -1 +1,2 @@
1
- export { };
1
+ export {};
2
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":""}
package/dist/run.js CHANGED
@@ -1,12 +1,90 @@
1
- import { runCalendarSyncFromEnv } from "./sync.js";
1
+ // @bun
2
+ // src/sync.ts
3
+ import { google } from "googleapis";
4
+ import { GoogleCalendarProvider } from "@contractspec/integration.providers-impls/impls/google-calendar";
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) {
11
+ return { created: eventInput, upcoming: [eventInput] };
12
+ }
13
+ const provider = createProviderFromEnv(calendarId);
14
+ const created = await provider.createEvent(eventInput);
15
+ const upcoming = await provider.listEvents(listQuery);
16
+ return { created, upcoming: upcoming.events };
17
+ }
18
+ function buildSampleEvent(calendarId) {
19
+ const start = new Date;
20
+ const end = new Date(start.getTime() + 30 * 60 * 1000);
21
+ return {
22
+ calendarId,
23
+ title: "Product sync review",
24
+ description: "Review onboarding friction and sync action items.",
25
+ location: "Zoom",
26
+ start,
27
+ end,
28
+ conference: { create: true, type: "google_meet" },
29
+ attendees: [{ email: "teammate@example.com", name: "Teammate" }],
30
+ reminders: [{ method: "popup", minutesBeforeStart: 10 }],
31
+ metadata: { source: "contractspec-example" }
32
+ };
33
+ }
34
+ function buildUpcomingQuery(calendarId) {
35
+ const now = new Date;
36
+ const inSevenDays = new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000);
37
+ return {
38
+ calendarId,
39
+ timeMin: now,
40
+ timeMax: inSevenDays,
41
+ maxResults: 5
42
+ };
43
+ }
44
+ function createProviderFromEnv(calendarId) {
45
+ const auth = createGoogleAuthFromEnv();
46
+ return new GoogleCalendarProvider({ auth, calendarId });
47
+ }
48
+ function createGoogleAuthFromEnv() {
49
+ const clientId = requireEnv("GOOGLE_CLIENT_ID");
50
+ const clientSecret = requireEnv("GOOGLE_CLIENT_SECRET");
51
+ const refreshToken = requireEnv("GOOGLE_REFRESH_TOKEN");
52
+ const redirectUri = process.env.GOOGLE_REDIRECT_URI ?? "https://developers.google.com/oauthplayground";
53
+ const oauth = new google.auth.OAuth2(clientId, clientSecret, redirectUri);
54
+ oauth.setCredentials({ refresh_token: refreshToken });
55
+ return oauth;
56
+ }
57
+ function resolveCalendarId() {
58
+ return process.env.GOOGLE_CALENDAR_ID ?? "primary";
59
+ }
60
+ function requireEnv(key) {
61
+ const value = process.env[key];
62
+ if (!value) {
63
+ throw new Error(buildMissingEnvMessage(key));
64
+ }
65
+ return value;
66
+ }
67
+ function buildMissingEnvMessage(key) {
68
+ if (key !== "GOOGLE_REFRESH_TOKEN") {
69
+ return `Missing required env var: ${key}`;
70
+ }
71
+ return [
72
+ `Missing required env var: ${key}`,
73
+ "Get a refresh token with OAuth Playground:",
74
+ "1) Open https://developers.google.com/oauthplayground",
75
+ '2) Click the gear icon and enable "Use your own OAuth credentials"',
76
+ "3) Enter GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET",
77
+ "4) Authorize scope https://www.googleapis.com/auth/calendar",
78
+ "5) Exchange for tokens and copy the refresh token",
79
+ "Then export GOOGLE_REFRESH_TOKEN and rerun the script."
80
+ ].join(`
81
+ `);
82
+ }
2
83
 
3
- //#region src/run.ts
84
+ // src/run.ts
4
85
  runCalendarSyncFromEnv().then((result) => {
5
- console.log(JSON.stringify(result, null, 2));
86
+ console.log(JSON.stringify(result, null, 2));
6
87
  }).catch((error) => {
7
- console.error(error);
8
- process.exitCode = 1;
88
+ console.error(error);
89
+ process.exitCode = 1;
9
90
  });
10
-
11
- //#endregion
12
- //# sourceMappingURL=run.js.map
package/dist/sync.d.ts CHANGED
@@ -1,14 +1,10 @@
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[];
1
+ import type { CalendarEvent, CalendarEventInput, CalendarListEventsQuery, CalendarProvider } from '@contractspec/integration.providers-impls/calendar';
2
+ export interface CalendarSyncOutput {
3
+ created?: CalendarEvent | CalendarEventInput;
4
+ upcoming: CalendarEvent[] | CalendarEventInput[];
7
5
  }
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 };
6
+ export declare function runCalendarSyncFromEnv(): Promise<CalendarSyncOutput>;
7
+ export declare function buildSampleEvent(calendarId: string): CalendarEventInput;
8
+ export declare function buildUpcomingQuery(calendarId: string): CalendarListEventsQuery;
9
+ export declare function createProviderFromEnv(calendarId: string): CalendarProvider;
14
10
  //# sourceMappingURL=sync.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EACjB,MAAM,oDAAoD,CAAC;AAE5D,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,aAAa,GAAG,kBAAkB,CAAC;IAC7C,QAAQ,EAAE,aAAa,EAAE,GAAG,kBAAkB,EAAE,CAAC;CAClD;AAED,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAc1E;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,CAevE;AAED,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,GACjB,uBAAuB,CASzB;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAG1E"}
package/dist/sync.js CHANGED
@@ -1,92 +1,88 @@
1
+ // @bun
2
+ // src/sync.ts
1
3
  import { google } from "googleapis";
2
4
  import { GoogleCalendarProvider } from "@contractspec/integration.providers-impls/impls/google-calendar";
3
-
4
- //#region src/sync.ts
5
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
- };
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) {
11
+ return { created: eventInput, upcoming: [eventInput] };
12
+ }
13
+ const provider = createProviderFromEnv(calendarId);
14
+ const created = await provider.createEvent(eventInput);
15
+ const upcoming = await provider.listEvents(listQuery);
16
+ return { created, upcoming: upcoming.events };
19
17
  }
20
18
  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
- };
19
+ const start = new Date;
20
+ const end = new Date(start.getTime() + 30 * 60 * 1000);
21
+ return {
22
+ calendarId,
23
+ title: "Product sync review",
24
+ description: "Review onboarding friction and sync action items.",
25
+ location: "Zoom",
26
+ start,
27
+ end,
28
+ conference: { create: true, type: "google_meet" },
29
+ attendees: [{ email: "teammate@example.com", name: "Teammate" }],
30
+ reminders: [{ method: "popup", minutesBeforeStart: 10 }],
31
+ metadata: { source: "contractspec-example" }
32
+ };
43
33
  }
44
34
  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
- };
35
+ const now = new Date;
36
+ const inSevenDays = new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000);
37
+ return {
38
+ calendarId,
39
+ timeMin: now,
40
+ timeMax: inSevenDays,
41
+ maxResults: 5
42
+ };
52
43
  }
53
44
  function createProviderFromEnv(calendarId) {
54
- return new GoogleCalendarProvider({
55
- auth: createGoogleAuthFromEnv(),
56
- calendarId
57
- });
45
+ const auth = createGoogleAuthFromEnv();
46
+ return new GoogleCalendarProvider({ auth, calendarId });
58
47
  }
59
48
  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;
49
+ const clientId = requireEnv("GOOGLE_CLIENT_ID");
50
+ const clientSecret = requireEnv("GOOGLE_CLIENT_SECRET");
51
+ const refreshToken = requireEnv("GOOGLE_REFRESH_TOKEN");
52
+ const redirectUri = process.env.GOOGLE_REDIRECT_URI ?? "https://developers.google.com/oauthplayground";
53
+ const oauth = new google.auth.OAuth2(clientId, clientSecret, redirectUri);
54
+ oauth.setCredentials({ refresh_token: refreshToken });
55
+ return oauth;
67
56
  }
68
57
  function resolveCalendarId() {
69
- return process.env.GOOGLE_CALENDAR_ID ?? "primary";
58
+ return process.env.GOOGLE_CALENDAR_ID ?? "primary";
70
59
  }
71
60
  function requireEnv(key) {
72
- const value = process.env[key];
73
- if (!value) throw new Error(buildMissingEnvMessage(key));
74
- return value;
61
+ const value = process.env[key];
62
+ if (!value) {
63
+ throw new Error(buildMissingEnvMessage(key));
64
+ }
65
+ return value;
75
66
  }
76
67
  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");
68
+ if (key !== "GOOGLE_REFRESH_TOKEN") {
69
+ return `Missing required env var: ${key}`;
70
+ }
71
+ return [
72
+ `Missing required env var: ${key}`,
73
+ "Get a refresh token with OAuth Playground:",
74
+ "1) Open https://developers.google.com/oauthplayground",
75
+ '2) Click the gear icon and enable "Use your own OAuth credentials"',
76
+ "3) Enter GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET",
77
+ "4) Authorize scope https://www.googleapis.com/auth/calendar",
78
+ "5) Exchange for tokens and copy the refresh token",
79
+ "Then export GOOGLE_REFRESH_TOKEN and rerun the script."
80
+ ].join(`
81
+ `);
88
82
  }
89
-
90
- //#endregion
91
- export { buildSampleEvent, buildUpcomingQuery, createProviderFromEnv, runCalendarSyncFromEnv };
92
- //# sourceMappingURL=sync.js.map
83
+ export {
84
+ runCalendarSyncFromEnv,
85
+ createProviderFromEnv,
86
+ buildUpcomingQuery,
87
+ buildSampleEvent
88
+ };
package/package.json CHANGED
@@ -1,52 +1,95 @@
1
1
  {
2
2
  "name": "@contractspec/example.calendar-google",
3
- "version": "1.57.0",
3
+ "version": "1.58.0",
4
4
  "description": "Google Calendar integration example: list and create events.",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
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
- "./*": "./*"
8
+ ".": "./src/index.ts",
9
+ "./docs": "./src/docs/index.ts",
10
+ "./docs/calendar-google.docblock": "./src/docs/calendar-google.docblock.ts",
11
+ "./docs/index": "./src/docs/index.ts",
12
+ "./example": "./src/example.ts",
13
+ "./run": "./src/run.ts",
14
+ "./sync": "./src/sync.ts"
15
15
  },
16
16
  "scripts": {
17
17
  "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
18
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",
19
+ "build": "bun run prebuild && bun run build:bundle && bun run build:types",
20
+ "build:bundle": "contractspec-bun-build transpile",
21
+ "build:types": "contractspec-bun-build types",
22
+ "dev": "contractspec-bun-build dev",
23
23
  "clean": "rimraf dist .turbo",
24
24
  "lint": "bun lint:fix",
25
25
  "lint:fix": "eslint src --fix",
26
26
  "lint:check": "eslint src",
27
- "test": "bun test"
27
+ "test": "bun test",
28
+ "prebuild": "contractspec-bun-build prebuild",
29
+ "typecheck": "tsc --noEmit"
28
30
  },
29
31
  "dependencies": {
30
- "@contractspec/integration.providers-impls": "1.57.0",
31
- "@contractspec/lib.contracts": "1.57.0",
32
+ "@contractspec/integration.providers-impls": "1.58.0",
33
+ "@contractspec/lib.contracts": "1.58.0",
32
34
  "googleapis": "^171.4.0"
33
35
  },
34
36
  "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"
37
+ "@contractspec/tool.typescript": "1.58.0",
38
+ "typescript": "^5.9.3",
39
+ "@contractspec/tool.bun": "1.57.0"
39
40
  },
40
41
  "publishConfig": {
41
42
  "access": "public",
42
43
  "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
- "./*": "./*"
44
+ ".": {
45
+ "types": "./dist/index.d.ts",
46
+ "bun": "./dist/index.js",
47
+ "node": "./dist/node/index.mjs",
48
+ "browser": "./dist/browser/index.js",
49
+ "default": "./dist/index.js"
50
+ },
51
+ "./docs": {
52
+ "types": "./dist/docs/index.d.ts",
53
+ "bun": "./dist/docs/index.js",
54
+ "node": "./dist/node/docs/index.mjs",
55
+ "browser": "./dist/browser/docs/index.js",
56
+ "default": "./dist/docs/index.js"
57
+ },
58
+ "./docs/calendar-google.docblock": {
59
+ "types": "./dist/docs/calendar-google.docblock.d.ts",
60
+ "bun": "./dist/docs/calendar-google.docblock.js",
61
+ "node": "./dist/node/docs/calendar-google.docblock.mjs",
62
+ "browser": "./dist/browser/docs/calendar-google.docblock.js",
63
+ "default": "./dist/docs/calendar-google.docblock.js"
64
+ },
65
+ "./docs/index": {
66
+ "types": "./dist/docs/index.d.ts",
67
+ "bun": "./dist/docs/index.js",
68
+ "node": "./dist/node/docs/index.mjs",
69
+ "browser": "./dist/browser/docs/index.js",
70
+ "default": "./dist/docs/index.js"
71
+ },
72
+ "./example": {
73
+ "types": "./dist/example.d.ts",
74
+ "bun": "./dist/example.js",
75
+ "node": "./dist/node/example.mjs",
76
+ "browser": "./dist/browser/example.js",
77
+ "default": "./dist/example.js"
78
+ },
79
+ "./run": {
80
+ "types": "./dist/run.d.ts",
81
+ "bun": "./dist/run.js",
82
+ "node": "./dist/node/run.mjs",
83
+ "browser": "./dist/browser/run.js",
84
+ "default": "./dist/run.js"
85
+ },
86
+ "./sync": {
87
+ "types": "./dist/sync.d.ts",
88
+ "bun": "./dist/sync.js",
89
+ "node": "./dist/node/sync.mjs",
90
+ "browser": "./dist/browser/sync.js",
91
+ "default": "./dist/sync.js"
92
+ }
50
93
  },
51
94
  "registry": "https://registry.npmjs.org/"
52
95
  },
package/tsdown.config.js CHANGED
@@ -1,5 +1,4 @@
1
- import { defineConfig } from 'tsdown';
2
- import { moduleLibrary } from '@contractspec/tool.tsdown';
1
+ import { defineConfig, moduleLibrary } from '@contractspec/tool.bun';
3
2
 
4
3
  export default defineConfig(() => ({
5
4
  ...moduleLibrary,
@@ -1,33 +0,0 @@
1
- $ tsdown
2
- ℹ tsdown v0.20.3 powered by rolldown v1.0.0-rc.3
3
- ℹ config file: /home/runner/work/contractspec/contractspec/packages/examples/calendar-google/tsdown.config.js
4
- ℹ entry: src/example.ts, src/index.ts, src/run.ts, src/sync.ts, src/docs/calendar-google.docblock.ts, src/docs/index.ts
5
- ℹ target: esnext
6
- ℹ tsconfig: tsconfig.json
7
- ℹ Build start
8
- ℹ Cleaning 19 files
9
- ℹ dist/sync.js 2.97 kB │ gzip: 1.25 kB
10
- ℹ dist/docs/calendar-google.docblock.js 1.62 kB │ gzip: 0.80 kB
11
- ℹ dist/example.js 0.96 kB │ gzip: 0.49 kB
12
- ℹ dist/run.js 0.28 kB │ gzip: 0.22 kB
13
- ℹ dist/index.js 0.28 kB │ gzip: 0.16 kB
14
- ℹ dist/docs/index.js 0.04 kB │ gzip: 0.06 kB
15
- ℹ dist/sync.js.map 5.05 kB │ gzip: 1.98 kB
16
- ℹ dist/docs/calendar-google.docblock.js.map 2.13 kB │ gzip: 0.98 kB
17
- ℹ dist/example.js.map 1.43 kB │ gzip: 0.69 kB
18
- ℹ dist/run.js.map 0.49 kB │ gzip: 0.33 kB
19
- ℹ dist/sync.d.ts.map 0.34 kB │ gzip: 0.21 kB
20
- ℹ dist/example.d.ts.map 0.13 kB │ gzip: 0.13 kB
21
- ℹ dist/sync.d.ts 0.78 kB │ gzip: 0.33 kB
22
- ℹ dist/index.d.ts 0.29 kB │ gzip: 0.15 kB
23
- ℹ dist/example.d.ts 0.25 kB │ gzip: 0.17 kB
24
- ℹ dist/docs/calendar-google.docblock.d.ts 0.01 kB │ gzip: 0.03 kB
25
- ℹ dist/docs/index.d.ts 0.01 kB │ gzip: 0.03 kB
26
- ℹ dist/run.d.ts 0.01 kB │ gzip: 0.03 kB
27
- ℹ 18 files, total: 17.06 kB
28
- [PLUGIN_TIMINGS] Warning: 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
- ✔ Build complete in 46144ms
@@ -1 +0,0 @@
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"}