Skip to content

Commit

Permalink
Merge branch 'main' into report-event-tranformer
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamlangford authored Jul 8, 2024
2 parents 0a8accc + 8de57df commit 804ae43
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 60 deletions.
4 changes: 2 additions & 2 deletions src/components/fields/schemaFields/fieldTypeCheckers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { isVarExpression } from "@/utils/expressionUtils";
import {
INTEGRATION_DEPENDENCY_FIELD_REFS,
PIXIEBRIX_INTEGRATION_REF_URL,
SERVICES_BASE_SCHEMA_URL,
INTEGRATIONS_BASE_SCHEMA_URL,
} from "@/integrations/constants";

export const isPixiebrixIntegrationField = createTypePredicate(
Expand All @@ -46,7 +46,7 @@ function isIntegrationRef(ref?: string): boolean {
}

return (
ref.startsWith(SERVICES_BASE_SCHEMA_URL) ||
ref.startsWith(INTEGRATIONS_BASE_SCHEMA_URL) ||
INTEGRATION_DEPENDENCY_FIELD_REFS.includes(ref)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/contrib/google/sheets/bricks/append.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { type SpreadsheetTarget } from "@/contrib/google/sheets/core/sheetsApi";
import { isNullOrBlank } from "@/utils/stringUtils";
import { isObject } from "@/utils/objectUtils";
import { propertiesToSchema } from "@/utils/schemaUtils";
import { SERVICES_BASE_SCHEMA_URL } from "@/integrations/constants";
import { INTEGRATIONS_BASE_SCHEMA_URL } from "@/integrations/constants";

type CellValue = string | number | null;

Expand All @@ -54,7 +54,7 @@ export const APPEND_SCHEMA: Schema = propertiesToSchema(
title: "Google Account",
oneOf: [
{
$ref: `${SERVICES_BASE_SCHEMA_URL}${GOOGLE_OAUTH2_PKCE_INTEGRATION_ID}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${GOOGLE_OAUTH2_PKCE_INTEGRATION_ID}`,
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions src/contrib/google/sheets/bricks/lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
} from "@/contrib/google/sheets/core/sheetsApi";
import { isNullOrBlank } from "@/utils/stringUtils";

import { SERVICES_BASE_SCHEMA_URL } from "@/integrations/constants";
import { INTEGRATIONS_BASE_SCHEMA_URL } from "@/integrations/constants";

export const GOOGLE_SHEETS_LOOKUP_ID = validateRegistryId(
"@pixiebrix/google/sheets-lookup",
Expand All @@ -46,7 +46,7 @@ export const LOOKUP_SCHEMA: Schema = {
title: "Google Account",
oneOf: [
{
$ref: `${SERVICES_BASE_SCHEMA_URL}${GOOGLE_OAUTH2_PKCE_INTEGRATION_ID}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${GOOGLE_OAUTH2_PKCE_INTEGRATION_ID}`,
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions src/integrations/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export const PIXIEBRIX_INTEGRATION_CONFIG_ID: UUID = uuidSequence(0);
export const PIXIEBRIX_OUTPUT_KEY = validateOutputKey("pixiebrix");
// We should probably leave this as called "SERVICES_" until if/when the actual url is changed
// to point to /schemas/integrations/, just as a reminder
export const SERVICES_BASE_SCHEMA_URL =
export const INTEGRATIONS_BASE_SCHEMA_URL =
"https://app.pixiebrix.com/schemas/services/";
export const PIXIEBRIX_INTEGRATION_REF_URL = `${SERVICES_BASE_SCHEMA_URL}${PIXIEBRIX_INTEGRATION_ID}`;
export const PIXIEBRIX_INTEGRATION_REF_URL = `${INTEGRATIONS_BASE_SCHEMA_URL}${PIXIEBRIX_INTEGRATION_ID}`;
export const PIXIEBRIX_INTEGRATION_FIELD_SCHEMA: Schema = {
$ref: PIXIEBRIX_INTEGRATION_REF_URL,
};
Expand Down
14 changes: 7 additions & 7 deletions src/integrations/util/getModDefinitionIntegrationIds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { modComponentDefinitionFactory } from "@/testUtils/factories/modDefiniti
import { validateOutputKey } from "@/runtime/runtimeTypes";
import getModDefinitionIntegrationIds from "@/integrations/util/getModDefinitionIntegrationIds";

import { SERVICES_BASE_SCHEMA_URL } from "@/integrations/constants";
import { INTEGRATIONS_BASE_SCHEMA_URL } from "@/integrations/constants";

describe("getModDefinitionIntegrationIds", () => {
it("works with record services formats", () => {
Expand Down Expand Up @@ -56,10 +56,10 @@ describe("getModDefinitionIntegrationIds", () => {
services: {
properties: {
service1: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${serviceId1}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${serviceId1}`,
},
service2: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${serviceId2}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${serviceId2}`,
},
},
required: ["service1", "service2"],
Expand All @@ -69,7 +69,7 @@ describe("getModDefinitionIntegrationIds", () => {
services: {
properties: {
service1: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${serviceId1}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${serviceId1}`,
},
},
required: ["service1"],
Expand All @@ -89,10 +89,10 @@ describe("getModDefinitionIntegrationIds", () => {
services: {
properties: {
service1: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${serviceId1}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${serviceId1}`,
},
service2: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${serviceId2}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${serviceId2}`,
},
},
required: ["service1", "service2"],
Expand All @@ -102,7 +102,7 @@ describe("getModDefinitionIntegrationIds", () => {
services: {
properties: {
service1: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${serviceId1}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${serviceId1}`,
},
},
required: ["service1"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import getUnconfiguredComponentIntegrations from "@/integrations/util/getUnconfi
import { validateRegistryId } from "@/types/helpers";
import { modComponentDefinitionFactory } from "@/testUtils/factories/modDefinitionFactories";
import { validateOutputKey } from "@/runtime/runtimeTypes";
import { SERVICES_BASE_SCHEMA_URL } from "@/integrations/constants";
import { INTEGRATIONS_BASE_SCHEMA_URL } from "@/integrations/constants";

describe("getUnconfiguredComponentIntegrations", () => {
it("returns empty if no integrations", () => {
Expand All @@ -36,10 +36,10 @@ describe("getUnconfiguredComponentIntegrations", () => {
services: {
properties: {
service1: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${serviceId1}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${serviceId1}`,
},
service2: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${serviceId2}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${serviceId2}`,
},
},
required: ["service1", "service2"],
Expand Down Expand Up @@ -85,10 +85,10 @@ describe("getUnconfiguredComponentIntegrations", () => {
services: {
properties: {
service1: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${serviceId1}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${serviceId1}`,
},
service2: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${serviceId2}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${serviceId2}`,
},
},
required: ["service1", "service2"],
Expand All @@ -100,11 +100,11 @@ describe("getUnconfiguredComponentIntegrations", () => {
properties: {
// Same outputKey as above for service1
service1: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${serviceId1}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${serviceId1}`,
},
// Unique outputKey for service2
service3: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${serviceId2}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${serviceId2}`,
},
},
required: ["service1", "service3"],
Expand Down Expand Up @@ -147,10 +147,10 @@ describe("getUnconfiguredComponentIntegrations", () => {
services: {
properties: {
service1: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${serviceId1}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${serviceId1}`,
},
service2: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${serviceId2}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${serviceId2}`,
},
},
required: [],
Expand Down
6 changes: 3 additions & 3 deletions src/pageEditor/documentBuilder/edit/DocumentOptions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ describe("DocumentOptions", () => {
// Integration dependencies included in the form state
const integrationDependencies: IntegrationDependency[] = [
integrationDependencyFactory({
integrationId: validateRegistryId("@test/service"),
outputKey: validateOutputKey("serviceOutput"),
integrationId: validateRegistryId("@test/integration"),
outputKey: validateOutputKey("integrationOuput"),
configId: uuidSequence,
}),
];
Expand All @@ -173,7 +173,7 @@ describe("DocumentOptions", () => {
id: validateRegistryId("@test/action"),
instanceId: uuidSequence(2),
config: {
input: toExpression("var", "@serviceOutput"),
input: toExpression("var", "@integrationOuput"),
},
},
]),
Expand Down
2 changes: 1 addition & 1 deletion src/pageEditor/documentBuilder/hooks/useDeleteElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function useDeleteElement(documentBodyName: string) {
elementsCollection.splice(Number(elementIndex), 1);
});

// If the element used a service, remove the service link as well
// If the element used an integration, remove the integration link as well
nextState = produceExcludeUnusedDependencies(nextState);

await setFormState(nextState);
Expand Down
8 changes: 4 additions & 4 deletions src/pageEditor/fields/FormRendererOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const databaseIdSchema: Schema = {
$ref: databaseSchema.$id,
};

function usePruneUnusedServiceDependencies() {
function usePruneUnusedIntegrationDependencies() {
const { values: formState, setValues: setFormState } =
useFormikContext<ModComponentFormState>();

Expand Down Expand Up @@ -86,15 +86,15 @@ const DEFAULT_STORAGE_TYPE = "state";
const FormDataBindingOptions: React.FC<{
makeName: (...names: string[]) => string;
}> = ({ makeName }) => {
const pruneDependencies = usePruneUnusedServiceDependencies();
const pruneDependencies = usePruneUnusedIntegrationDependencies();

const [{ value: storage }, , { setValue: setStorageValue }] =
useField<Storage>(makeName("storage"));

const storageType = storage?.type;

// Sets the storage type and clears out any other values the user might have configured
// If the next type is "database", the AppServiceField will initialize the "service" variable
// If the next type is "database", the "service" variable will be initialized
const changeStorageType = async (nextStorageType: string) => {
if (nextStorageType === "state") {
await setStorageValue({
Expand All @@ -106,7 +106,7 @@ const FormDataBindingOptions: React.FC<{
}
};

// If the storage type changes from "database" to something else, ensure the service record at root is cleared
// If the storage type changes from "database" to something else, ensure the "service" record at root is cleared
const [previousStorageType, setPreviousStorageType] = useState(storageType);
useAsyncEffect(async () => {
if (
Expand Down
16 changes: 8 additions & 8 deletions src/pageEditor/panes/save/saveHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ import {
emptyModOptionsDefinitionFactory,
normalizeModDefinition,
} from "@/utils/modUtils";
import { SERVICES_BASE_SCHEMA_URL } from "@/integrations/constants";
import { INTEGRATIONS_BASE_SCHEMA_URL } from "@/integrations/constants";
import { registryIdFactory } from "@/testUtils/factories/stringFactories";

jest.mock("@/pageEditor/starterBricks/base", () => ({
Expand Down Expand Up @@ -625,7 +625,7 @@ describe("buildNewMod", () => {
expect(newMod.extensionPoints[0].id).toBe(modComponent.extensionPointId);
});

test("Dirty mod component with services", async () => {
test("Dirty mod component with integrations", async () => {
const integrationId = validateRegistryId("@pixiebrix/api");
const outputKey = validateOutputKey("pixiebrix");

Expand Down Expand Up @@ -869,7 +869,7 @@ describe("buildNewMod", () => {
);
});

describe("findMaxServicesDependencyApiVersion", () => {
describe("findMaxIntegrationDependencyApiVersion", () => {
it("returns v1 for v1 dependencies", () => {
const dependencies: Array<Pick<IntegrationDependency, "apiVersion">> = [
{
Expand Down Expand Up @@ -923,7 +923,7 @@ describe("findMaxServicesDependencyApiVersion", () => {
});

describe("selectModComponentIntegrations", () => {
it("works for v1 services", () => {
it("works for v1 integrations", () => {
const modComponent: Pick<ModComponentBase, "integrationDependencies"> = {
integrationDependencies: [
integrationDependencyFactory(),
Expand All @@ -941,7 +941,7 @@ describe("selectModComponentIntegrations", () => {
});
});

it("works for v2 services", () => {
it("works for v2 integrations", () => {
const modComponent: Pick<ModComponentBase, "integrationDependencies"> = {
integrationDependencies: [
integrationDependencyFactory({
Expand All @@ -961,13 +961,13 @@ describe("selectModComponentIntegrations", () => {
expect(selectModComponentIntegrations(modComponent)).toStrictEqual({
properties: {
[modComponent.integrationDependencies[0].outputKey]: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${modComponent.integrationDependencies[0].integrationId}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${modComponent.integrationDependencies[0].integrationId}`,
},
[modComponent.integrationDependencies[1].outputKey]: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${modComponent.integrationDependencies[1].integrationId}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${modComponent.integrationDependencies[1].integrationId}`,
},
[modComponent.integrationDependencies[2].outputKey]: {
$ref: `${SERVICES_BASE_SCHEMA_URL}${modComponent.integrationDependencies[2].integrationId}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${modComponent.integrationDependencies[2].integrationId}`,
},
},
required: [modComponent.integrationDependencies[1].outputKey],
Expand Down
4 changes: 2 additions & 2 deletions src/pageEditor/panes/save/saveHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {
} from "@/integrations/integrationTypes";
import { type Schema } from "@/types/schemaTypes";
import { normalizeModOptionsDefinition } from "@/utils/modUtils";
import { SERVICES_BASE_SCHEMA_URL } from "@/integrations/constants";
import { INTEGRATIONS_BASE_SCHEMA_URL } from "@/integrations/constants";
import {
isStarterBrickDefinitionLike,
type StarterBrickDefinitionLike,
Expand Down Expand Up @@ -173,7 +173,7 @@ export function selectModComponentIntegrations({
isOptional,
} of _integrationDependencies) {
properties[outputKey] = {
$ref: `${SERVICES_BASE_SCHEMA_URL}${integrationId}`,
$ref: `${INTEGRATIONS_BASE_SCHEMA_URL}${integrationId}`,
};
if (!isOptional) {
required.push(outputKey);
Expand Down
16 changes: 8 additions & 8 deletions src/pageEditor/store/editor/editorSlice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ function getTabState(
.nodeUIStates[FOUNDATION_NODE_ID].dataPanel[tabKey];
}

const GOOGLE_SHEET_SERVICE_ID = validateRegistryId("google/sheet");
const GOOGLE_SHEET_INTEGRATION_ID = validateRegistryId("google/sheet");

const standardBrick = brickConfigFactory({
id: teapotBrick.id,
outputKey: "teapotOutput" as OutputKey,
config: defaultBrickConfig(teapotBrick.inputSchema),
});

const brickWithService = brickConfigFactory({
const brickWithIntegration = brickConfigFactory({
id: echoBrick.id,
outputKey: "echoOutput" as OutputKey,
config: {
Expand Down Expand Up @@ -132,13 +132,13 @@ describe("Add/Remove Bricks", () => {
label: "Test Mod Component",
integrationDependencies: [
integrationDependencyFactory({
integrationId: GOOGLE_SHEET_SERVICE_ID,
integrationId: GOOGLE_SHEET_INTEGRATION_ID,
outputKey: "google" as OutputKey,
configId: uuidSequence,
}),
],
},
[brickWithService, standardBrick],
[brickWithIntegration, standardBrick],
);

beforeEach(() => {
Expand Down Expand Up @@ -182,7 +182,7 @@ describe("Add/Remove Bricks", () => {
// Remove the brick with integration dependency
editor = editorSlice.reducer(
editor,
actions.removeNode(brickWithService.instanceId),
actions.removeNode(brickWithIntegration.instanceId),
);

// Ensure Integration Dependency was removed
Expand All @@ -195,19 +195,19 @@ describe("Add/Remove Bricks", () => {
});

test("Remove Brick without Integration Dependency", async () => {
// Get initial bricks and services
// Get initial bricks and integrations
const initialBricks =
editor.modComponentFormStates[0].modComponent.brickPipeline;
const initialIntegrationDependencies =
editor.modComponentFormStates[0].integrationDependencies;

// Remove the brick with service
// Remove the brick with integration
editor = editorSlice.reducer(
editor,
actions.removeNode(standardBrick.instanceId),
);

// Ensure Service was NOT removed
// Ensure integration was NOT removed
expect(
editor.modComponentFormStates[0].modComponent.brickPipeline,
).toBeArrayOfSize(initialBricks.length - 1);
Expand Down
Loading

0 comments on commit 804ae43

Please sign in to comment.