Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions packages/plugins/google/src/api/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,41 @@ const AddBundleResponse = Schema.Struct({
toolCount: Schema.Number,
});

const AddServicePayload = Schema.Struct({
presetId: Schema.String,
slug: Schema.optional(Schema.String),
name: Schema.optional(Schema.String),
});

const AddServicesPayload = Schema.Struct({
services: Schema.Array(AddServicePayload),
baseUrl: Schema.optional(Schema.String),
});

const AddServicesResponse = Schema.Struct({
added: Schema.Array(
Schema.Struct({
slug: IntegrationSlug,
presetId: Schema.String,
toolCount: Schema.Number,
}),
),
skipped: Schema.Array(
Schema.Struct({
slug: IntegrationSlug,
presetId: Schema.String,
reason: Schema.Literal("already_exists"),
}),
),
failed: Schema.Array(
Schema.Struct({
slug: IntegrationSlug,
presetId: Schema.String,
error: Schema.String,
}),
),
});

const UpdateBundlePayload = Schema.Struct({
urls: Schema.optional(Schema.Array(Schema.String)),
});
Expand Down Expand Up @@ -103,6 +138,13 @@ export const GoogleGroup = HttpApiGroup.make("google")
error: DomainErrors,
}),
)
.add(
HttpApiEndpoint.post("addServices", "/google/services", {
payload: AddServicesPayload,
success: AddServicesResponse,
error: DomainErrors,
}),
)
.add(
HttpApiEndpoint.get("getIntegration", "/google/integrations/:slug", {
params: SlugParams,
Expand Down
11 changes: 11 additions & 0 deletions packages/plugins/google/src/api/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ export const GoogleHandlers = HttpApiBuilder.group(ExecutorApiWithGoogle, "googl
}),
),
)
.handle("addServices", ({ payload }) =>
capture(
Effect.gen(function* () {
const ext = yield* GoogleExtensionService;
return yield* ext.addServices({
services: payload.services,
baseUrl: payload.baseUrl,
});
}),
),
)
.handle("getIntegration", ({ params }) =>
capture(
Effect.gen(function* () {
Expand Down
2 changes: 2 additions & 0 deletions packages/plugins/google/src/react/atoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export const googleConfigAtom = (slug: IntegrationSlug) =>

export const addGoogleBundle = GoogleClient.mutation("google", "addBundle");

export const addGoogleServices = GoogleClient.mutation("google", "addServices");

export const updateGoogleBundle = GoogleClient.mutation("google", "updateBundle");

export const removeGoogleBundle = GoogleClient.mutation("google", "removeBundle");
Expand Down
1 change: 1 addition & 0 deletions packages/plugins/google/src/react/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export { googleIntegrationPlugin } from "./source-plugin";
export { GoogleClient } from "./client";
export {
addGoogleBundle,
addGoogleServices,
googleConfigAtom,
googleConfigFamily,
googleConfigure,
Expand Down
7 changes: 7 additions & 0 deletions packages/plugins/google/src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export {
GOOGLE_PHOTOS_ICON,
GOOGLE_PHOTOS_PRESET_ID,
googleStandardUserOAuthPresets,
googleServiceSlug,
googleOAuthConsentScopes,
googleOAuthConsentScopesForPreset,
googleAudienceWarningsForUrls,
Expand All @@ -34,10 +35,16 @@ export {
} from "./oauth-batches";
export {
googlePlugin,
type GoogleAddServicesAdded,
type GoogleAddServicesFailed,
type GoogleAddServicesInput,
type GoogleAddServicesResult,
type GoogleAddServicesSkipped,
type GoogleBundleConfig,
type GoogleConfigureInput,
type GooglePluginExtension,
type GooglePluginOptions,
type GoogleServiceConfig,
type GoogleUpdateInput,
type GoogleUpdateResult,
} from "./plugin";
Expand Down
Loading
Loading