Skip to content

Commit

Permalink
qq
Browse files Browse the repository at this point in the history
  • Loading branch information
Faten848 committed Oct 8, 2024
1 parent 934c38a commit f419c5f
Show file tree
Hide file tree
Showing 56 changed files with 228 additions and 276 deletions.
6 changes: 3 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
DUMMY_EMAIL_TRANSPORTER_FILE_PATH=var/api/dummy-email-transporter/email-dumps.yml
DUMMY_EMAIL_TRANSPORTER_USE_CLIPBOARD=true

FRONTEND_URL=http://localhost:3000
HASH_GRAPH_ALLOWED_URL_DOMAIN_PATTERN="(?:http://localhost:3000|https://hash\\.ai)/@(?P<shortname>[\\w-]+)/types/(?P<kind>(?:data-type)|(?:property-type)|(?:entity-type))/[\\w\\-_%]+/"
FRONTEND_URL=http://localhost:3001
HASH_GRAPH_ALLOWED_URL_DOMAIN_PATTERN="(?:http://localhost:3455|https://hash\\.ai)/@(?P<shortname>[\\w-]+)/types/(?P<kind>(?:data-type)|(?:property-type)|(?:entity-type))/[\\w\\-_%]+/"

HASH_INTEGRATION_QUEUE_NAME=integration
HASH_EMAIL_TRANSPORTER=dummy
Expand All @@ -20,7 +20,7 @@ HASH_OPENSEARCH_PASSWORD=admin
HASH_OPENSEARCH_PORT=9200
HASH_OPENSEARCH_USERNAME=admin

POSTGRES_PORT=5432
POSTGRES_PORT=54334

POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
Expand Down
4 changes: 2 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ HASH_GRAPH_PG_DATABASE=dev_graph
AWS_REGION=local
AWS_S3_UPLOADS_ENDPOINT=http://localhost:9000
AWS_S3_UPLOADS_BUCKET="dev-hash-bucket"
AWS_S3_UPLOADS_ACCESS_KEY_ID="dev-s3-access-key-id"
AWS_S3_UPLOADS_SECRET_ACCESS_KEY="dev-s3-secret-access-key"
AWS_S3_UPLOADS_ACCESS_KEY_ID="admin"
AWS_S3_UPLOADS_SECRET_ACCESS_KEY="password123"
AWS_S3_UPLOADS_FORCE_PATH_STYLE=true
FILE_UPLOAD_PROVIDER="AWS_S3"

Expand Down
6 changes: 3 additions & 3 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ HASH_KRATOS_PG_DATABASE=test_kratos
HASH_TEMPORAL_PG_DATABASE=test_temporal
HASH_TEMPORAL_VISIBILITY_PG_DATABASE=test_temporal_visibility
HASH_GRAPH_PG_DATABASE=test_graph
HASH_GRAPH_ALLOWED_URL_DOMAIN_PATTERN="(?:http://localhost:3000|https://hash\\.ai)/@(?P<shortname>[\\w-]+)/types/(?P<kind>(?:data-type)|(?:property-type)|(?:entity-type))/[\\w\\-_%]+/"
HASH_GRAPH_ALLOWED_URL_DOMAIN_PATTERN="(?:http://localhost:3455|https://hash\\.ai)/@(?P<shortname>[\\w-]+)/types/(?P<kind>(?:data-type)|(?:property-type)|(?:entity-type))/[\\w\\-_%]+/"

# For locally-running minio instance
AWS_REGION=local
AWS_S3_UPLOADS_ENDPOINT=http://localhost:9000
AWS_S3_UPLOADS_BUCKET="dev-hash-bucket"
AWS_S3_UPLOADS_ACCESS_KEY_ID="dev-s3-access-key-id"
AWS_S3_UPLOADS_SECRET_ACCESS_KEY="dev-s3-secret-access-key"
AWS_S3_UPLOADS_ACCESS_KEY_ID="admin"
AWS_S3_UPLOADS_SECRET_ACCESS_KEY="password123"
AWS_S3_UPLOADS_FORCE_PATH_STYLE=true
FILE_UPLOAD_PROVIDER="AWS_S3"
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const createColumnsForEntity = (

for (const { schema } of entityTypeAndParents) {
for (const baseUrl of typedKeys(schema.properties)) {
properties.add(baseUrl as BaseUrl);
properties.add(baseUrl);
}
for (const linkTypeId of typedKeys(schema.links ?? {})) {
links.add(linkTypeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export const dereferenceEntityType = <

for (const entityType of entityTypeWithAncestors) {
for (const requiredProp of entityType.schema.required ?? []) {
requiredProperties.add(requiredProp as BaseUrl);
requiredProperties.add(requiredProp);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-api/src/graph/ontology/primitive/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const isExternalTypeId = (typeId: VersionedUrl) =>
// To be removed in H-1172: Temporary provision to serve types with a https://hash.ai URL from https://app.hash.ai
!(
!isSelfHostedInstance &&
["https://app.hash.ai", "http://localhost:3000"].includes(frontendUrl) &&
["https://app.hash.ai", "http://localhost:3455"].includes(frontendUrl) &&
new URL(typeId).hostname === "hash.ai"
);

Expand Down
4 changes: 2 additions & 2 deletions apps/hash-api/src/graphql/resolvers/ontology/entity-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const createEntityTypeResolver: ResolverFn<
ownedById: ownedById ?? (user.accountId as OwnedById),
schema: entityType,
icon: params.icon ?? undefined,
labelProperty: (params.labelProperty as BaseUrl | undefined) ?? undefined,
labelProperty: params.labelProperty ?? undefined,
relationships: defaultEntityTypeAuthorizationRelationships,
});

Expand Down Expand Up @@ -159,7 +159,7 @@ export const updateEntityTypeResolver: ResolverFn<
{
entityTypeId: params.entityTypeId,
schema: params.updatedEntityType,
labelProperty: (params.labelProperty as BaseUrl | undefined) ?? undefined,
labelProperty: params.labelProperty ?? undefined,
icon: params.icon ?? undefined,
relationships: [
{
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ const main = async () => {
*
* When setting the value of the `Access-Control-Allow-Origin` header in
* the Ory Kratos configuration, the frontend URL is included twice in the
* header for some reason (e.g. ["https://localhost:3000", "https://localhost:3000"]),
* header for some reason (e.g. ["https://localhost:3455", "https://localhost:3455"]),
* which is also not permitted by browsers when including credentials in requests.
*
* Therefore we manually set the `Access-Control-Allow-Origin` header to the
Expand Down
36 changes: 1 addition & 35 deletions apps/hash-external-services/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,7 @@ services:
HASH_SPICEDB_PG_PASSWORD: "${HASH_SPICEDB_PG_PASSWORD}"
HASH_SPICEDB_PG_DATABASE: "${HASH_SPICEDB_PG_DATABASE}"
ports:
- "${POSTGRES_PORT}:5432"

minio:
image: quay.io/minio/minio
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: ${AWS_S3_UPLOADS_ACCESS_KEY_ID}
MINIO_ROOT_PASSWORD: ${AWS_S3_UPLOADS_SECRET_ACCESS_KEY}
ports:
- 9000:9000
- 9001:9001
volumes:
- ../../var/uploads/s3:/data

minio-ensure-bucket-exists:
image: minio/mc
depends_on:
- minio
security_opt:
- no-new-privileges:true
environment:
MINIO_ROOT_USER: ${AWS_S3_UPLOADS_ACCESS_KEY_ID}
MINIO_ROOT_PASSWORD: ${AWS_S3_UPLOADS_SECRET_ACCESS_KEY}
AWS_S3_UPLOADS_BUCKET: ${AWS_S3_UPLOADS_BUCKET}
entrypoint: >
/bin/sh -c "
# Wait until MinIO is accessible
until (mc config host add myminio http://minio:9000 \$MINIO_ROOT_USER \$MINIO_ROOT_PASSWORD) do echo 'Waiting for MinIO...' && sleep 1; done;
# Add a fixed delay to ensure MinIO server is fully ready
sleep 5;
echo 'Creating bucket if not exists...';
mc mb myminio/\$AWS_S3_UPLOADS_BUCKET --ignore-existing;
"
- "${POSTGRES_PORT}:54334"

telemetry-collector:
image: jaegertracing/all-in-one:1.48
Expand Down
4 changes: 2 additions & 2 deletions apps/hash-external-services/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
HASH_SPICEDB_PG_PASSWORD: "${HASH_SPICEDB_PG_PASSWORD}"
HASH_SPICEDB_PG_DATABASE: "${HASH_SPICEDB_PG_DATABASE}"
ports:
- "${POSTGRES_PORT}:5432"
- "${POSTGRES_PORT}:54334"

kratos-migrate:
build:
Expand Down Expand Up @@ -259,4 +259,4 @@ services:
API_ORIGIN: "http://hash-api:5001"

ports:
- "3000:3000"
- "3000:3455"
14 changes: 1 addition & 13 deletions apps/hash-external-services/docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
services:
postgres:
ports:
- "${POSTGRES_PORT}:5432"

minio:
image: quay.io/minio/minio
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: ${AWS_S3_UPLOADS_ACCESS_KEY_ID}
MINIO_ROOT_PASSWORD: ${AWS_S3_UPLOADS_SECRET_ACCESS_KEY}
ports:
- 9000:9000
- 9001:9001
volumes:
- ../../var/uploads/s3:/data
- "${POSTGRES_PORT}:54334"

minio-ensure-bucket-exists:
image: minio/mc
Expand Down
8 changes: 4 additions & 4 deletions apps/hash-external-services/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ services:
DB: "postgres12"
DBNAME: "${HASH_TEMPORAL_PG_DATABASE}"
VISIBILITY_DBNAME: "${HASH_TEMPORAL_VISIBILITY_PG_DATABASE}"
DB_PORT: "5432"
DB_PORT: "54334"
# Intentionally use the POSTGRES user as it's the "superadmin" which has access to schema
POSTGRES_USER: "${POSTGRES_USER}"
POSTGRES_PWD: "${POSTGRES_PASSWORD}"
Expand Down Expand Up @@ -230,7 +230,7 @@ services:
DB: "postgres12"
DBNAME: "${HASH_TEMPORAL_PG_DATABASE}"
VISIBILITY_DBNAME: "${HASH_TEMPORAL_VISIBILITY_PG_DATABASE}"
DB_PORT: "5432"
DB_PORT: "54334"
POSTGRES_USER: "${HASH_TEMPORAL_PG_USER}"
POSTGRES_PWD: "${HASH_TEMPORAL_PG_PASSWORD}"
POSTGRES_SEEDS: "postgres" # the hostname of the postgres container
Expand All @@ -257,7 +257,7 @@ services:
DB: "postgres12"
DBNAME: "${HASH_TEMPORAL_PG_DATABASE}"
VISIBILITY_DBNAME: "${HASH_TEMPORAL_VISIBILITY_PG_DATABASE}"
DB_PORT: "5432"
DB_PORT: "54334"
# Intentionally use the POSTGRES user as it's the "superadmin" which has access to schema
POSTGRES_USER: "${POSTGRES_USER}"
POSTGRES_PWD: "${POSTGRES_PASSWORD}"
Expand All @@ -279,7 +279,7 @@ services:
condition: service_completed_successfully
environment:
TEMPORAL_ADDRESS: temporal:7233
TEMPORAL_CORS_ORIGINS: http://localhost:3000
TEMPORAL_CORS_ORIGINS: http://localhost:3455
security_opt:
- no-new-privileges:true
ports:
Expand Down
20 changes: 10 additions & 10 deletions apps/hash-external-services/kratos/kratos.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ session:
lifespan: 26280h # 24 h * 365 days * 3 years

selfservice:
default_browser_return_url: http://localhost:3000/
default_browser_return_url: http://localhost:3455/
allowed_return_urls:
- http://localhost:3000
- http://localhost:3455

methods:
password:
Expand All @@ -27,27 +27,27 @@ selfservice:
# but we're using the code method, so we disable this method for usage.
enabled: false
# Set through SELFSERVICE_METHODS_LINK_CONFIG_BASE_URL
base_url: http://localhost:3000/api/ory
base_url: http://localhost:3455/api/ory
code:
config:
# and make sure to enable the code method.
enabled: true

flows:
error:
ui_url: http://localhost:3000/error
ui_url: http://localhost:3455/error

logout:
after:
default_browser_return_url: http://localhost:3000/signin
default_browser_return_url: http://localhost:3455/signin

login:
ui_url: http://localhost:3000/signin
ui_url: http://localhost:3455/signin
lifespan: 10m

registration:
lifespan: 10m
ui_url: http://localhost:3000/signup
ui_url: http://localhost:3455/signup
after:
password:
hooks:
Expand Down Expand Up @@ -76,18 +76,18 @@ selfservice:
use: code
lifespan: 48h
# Set though SELFSERVICE_FLOWS_VERIFICATION_UI_URL
ui_url: http://localhost:3000/verification
ui_url: http://localhost:3455/verification
enabled: true

recovery:
enabled: true
# Set through SELFSERVICE_FLOWS_RECOVERY_UI_URL
ui_url: http://localhost:3000/recovery
ui_url: http://localhost:3455/recovery
use: code

settings:
# Set through SELFSERVICE_FLOWS_SETTINGS_UI_URL
ui_url: http://localhost:3000/change-password
ui_url: http://localhost:3455/change-password

log:
level: debug
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ npm run dev
yarn dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
Open [http://localhost:3455](http://localhost:3455) with your browser to see the result.
4 changes: 2 additions & 2 deletions apps/hash-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"lint:eslint": "eslint --report-unused-disable-directives .",
"lint:tsc": "tsc --noEmit",
"start": "next start",
"start:healthcheck": "wait-on --timeout 600000 http://0.0.0.0:3000",
"start:healthcheck": "wait-on --timeout 600000 http://0.0.0.0:3455",
"start:test": "next start",
"start:test:healthcheck": "wait-on --timeout 600000 http://0.0.0.0:3000"
"start:test:healthcheck": "wait-on --timeout 600000 http://0.0.0.0:3455"
},
"dependencies": {
"@apollo/client": "3.10.5",
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-frontend/src/middleware/return-types-as-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const returnTypeAsJson = async (request: NextRequest) => {
const urlObject = new URL(url);
const shouldServeHashAiType =
frontendUrl === "https://app.hash.ai" ||
(frontendUrl === "http://localhost:3000" &&
(frontendUrl === "http://localhost:3455" &&
["hash", "google", "linear"].includes(
urlObject.pathname.split("/")[1]!.slice(1),
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const ArrayEditor: ValueCellEditorComponent = ({
}

if (expectedTypes.length === 1) {
const expectedType = guessEditorTypeFromExpectedType(expectedTypes[0]!);
const expectedType = guessEditorTypeFromExpectedType(expectedTypes[0]);

if (getEditorSpecs(expectedType).arrayEditException === "no-edit-mode") {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export const getExpectedTypesOfPropertyType = (
*/
const firstType = propertyType.oneOf[0];

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- improve logic or types to remove this comment
if (!firstType) {
throw new Error("There is no type in this property");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getEntityTypeBaseUrl = (
([...systemTypeWebShortnames, "ftse"].includes(
namespaceWithAt.slice(1) as SystemTypeWebShortname,
) &&
frontendUrl === "http://localhost:3000") ||
frontendUrl === "http://localhost:3455") ||
frontendUrl === "https://app.hash.ai"
? "https://hash.ai"
: frontendUrl
Expand Down
7 changes: 4 additions & 3 deletions apps/hash-frontend/src/pages/shared/data-types-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ export const DataTypesContextProvider = ({ children }: PropsWithChildren) => {
({ dataTypeId, value }: { dataTypeId: VersionedUrl; value: JsonValue }) => {
const { baseUrl, version } = componentsFromVersionedUrl(dataTypeId);

const dataType = data?.queryDataTypes.vertices[baseUrl]?.[
version as unknown as OntologyTypeRevisionId
]?.inner.schema as DataTypeWithMetadata["schema"] | undefined;
const dataType =
data?.queryDataTypes.vertices[baseUrl][
version as unknown as OntologyTypeRevisionId
]?.inner.schema;

if (!dataType) {
return formatDataValue(value?.toString() ?? "null", undefined);
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-frontend/src/pages/shared/entities-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const EntitiesTable: FunctionComponent<{
*/
(entityTypes?.length &&
entityTypes.every(
({ $id }) => isSpecialEntityTypeLookup?.[$id]?.isFile,
({ $id }) => isSpecialEntityTypeLookup?.[$id].isFile,
)),
[entityTypeBaseUrl, entityTypeId, entityTypes, isSpecialEntityTypeLookup],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const EntityTypeSelector = <Multiple extends boolean = false>({
uniqueId: $id,
icon:
icon ??
(isSpecialEntityTypeLookup?.[$id]?.isLink ? (
(isSpecialEntityTypeLookup?.[$id].isLink ? (
<LinkTypeIcon />
) : (
<EntityTypeIcon />
Expand Down
4 changes: 2 additions & 2 deletions apps/hash-frontend/src/pages/shared/type-graph-visualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const TypeGraphVisualizer = ({

const entityTypeId = schema.$id;

const isLink = isSpecialEntityTypeLookup?.[entityTypeId]?.isLink;
const isLink = isSpecialEntityTypeLookup?.[entityTypeId].isLink;
if (isLink) {
/**
* We'll add the links as we process each entity type – this means that any link types which are unused won't
Expand Down Expand Up @@ -125,7 +125,7 @@ export const TypeGraphVisualizer = ({

if (destinationTypeIds) {
for (const destinationTypeId of destinationTypeIds) {
if (isSpecialEntityTypeLookup?.[destinationTypeId]?.isLink) {
if (isSpecialEntityTypeLookup?.[destinationTypeId].isLink) {
/**
* If the destination is itself a link, we need to account for the multiple places the destination link
* may appear. We won't have the full set until we've gone through all the non-link entity types,
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-frontend/src/shared/is-href-external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const isHrefExternal = (href: string) =>
// To be removed in H-1172: Temporary provision to serve types with a https://hash.ai URL from https://app.hash.ai
!(
process.env.NEXT_PUBLIC_SELF_HOSTED_HASH !== "true" &&
["https://app.hash.ai", "http://localhost:3000"].includes(frontendUrl) &&
["https://app.hash.ai", "http://localhost:3455"].includes(frontendUrl) &&
(href.startsWith("#") ||
href.startsWith("/") ||
new URL(href).hostname === "hash.ai")
Expand Down
Loading

0 comments on commit f419c5f

Please sign in to comment.