Skip to content
Merged
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
11 changes: 0 additions & 11 deletions .github/workflows/awsdeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,3 @@ jobs:
secrets:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}

deploy-site-builder:
uses: ./.github/workflows/deploy-template.yml
with:
service: site-builder
environment: ${{ inputs.environment }}
proper-name: ${{ inputs.proper-name }}
image-tag-override: ${{ inputs.image-tag-override }}
secrets:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,5 @@ jobs:
if: matrix.task == 'test-run'
run: pnpm test:setup

- name: Run migrations
if: matrix.task == 'test-run'
run: pnpm --filter core migrate-test

- name: Run task
run: NODE_ENV=test pnpm ${{ matrix.task }}
3 changes: 0 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ jobs:
echo "core_label=$ECR_REGISTRY/${ECR_REPOSITORY_NAME_OVERRIDE:-$ECR_REPOSITORY_PREFIX-core}:$IMAGE_TAG" >> $GITHUB_OUTPUT
echo "jobs_label=$ECR_REGISTRY/${ECR_REPOSITORY_NAME_OVERRIDE:-$ECR_REPOSITORY_PREFIX-jobs}:$IMAGE_TAG" >> $GITHUB_OUTPUT
echo "base_label=$ECR_REGISTRY/$ECR_REPOSITORY_PREFIX:$IMAGE_TAG" >> $GITHUB_OUTPUT
echo "site_builder_label=$ECR_REGISTRY/${ECR_REPOSITORY_NAME_OVERRIDE:-$ECR_REPOSITORY_PREFIX-site-builder}:$IMAGE_TAG" >> $GITHUB_OUTPUT

- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline
Expand All @@ -125,7 +124,6 @@ jobs:
run: pnpm integration:setup
env:
INTEGRATION_TESTS_IMAGE: ${{steps.label.outputs.core_label}}
SITE_BUILDER_IMAGE: ${{steps.label.outputs.site_builder_label}}
JOBS_IMAGE: ${{steps.label.outputs.jobs_label}}

- name: Log out Container ID for health check
Expand All @@ -147,7 +145,6 @@ jobs:
run: docker compose -f docker-compose.test.yml --profile integration logs -t
env:
INTEGRATION_TESTS_IMAGE: ${{steps.label.outputs.core_label}}
SITE_BUILDER_IMAGE: ${{steps.label.outputs.site_builder_label}}
JOBS_IMAGE: ${{steps.label.outputs.jobs_label}}

- name: Upload core playwright snapshots artifact
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/ecrbuild-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ on:
jobs-image:
description: "Jobs image SHA"
value: ${{ jobs.build-jobs.outputs.image-sha }}
site-builder-image:
description: "Site builder image SHA"
value: ${{ jobs.build-site-builder.outputs.image-sha }}

jobs:
emit-sha-tag:
Expand Down Expand Up @@ -77,13 +74,3 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}

build-site-builder:
uses: ./.github/workflows/ecrbuild-template.yml
with:
package: site-builder
target: jobs
publish_to_ghcr: ${{ inputs.publish_to_ghcr }}
ghcr_image_name: platform-site-builder
secrets:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
1 change: 0 additions & 1 deletion .github/workflows/on_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ jobs:
PLATFORM_IMAGE: ${{ needs.build-all.outputs.core-image }}
JOBS_IMAGE: ${{ needs.build-all.outputs.jobs-image }}
MIGRATIONS_IMAGE: ${{ needs.build-all.outputs.base-image }}
SITE_BUILDER_IMAGE: ${{ needs.build-all.outputs.site-builder-image }}
AWS_REGION: "us-east-1"
ALWAYS_ON: "main"
COMPOSE_FILES: docker-compose.preview.sandbox.yml
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,9 @@ jobs:
# PLATFORM_IMAGE: 246372085946.dkr.ecr.us-east-1.amazonaws.com/pubpub-v7-core:2b9a81a279c4e405bbedcdbb697c897ded52fbc0
# JOBS_IMAGE: 246372085946.dkr.ecr.us-east-1.amazonaws.com/pubpub-v7-jobs:c786662f4899de16a621e366a485eca5adda4d6a
# MIGRATIONS_IMAGE: 246372085946.dkr.ecr.us-east-1.amazonaws.com/pubpub-v7:c786662f4899de16a621e366a485eca5adda4d6a
# SITE_BUILDER_IMAGE: 246372085946.dkr.ecr.us-east-1.amazonaws.com/pubpub-v7-site-builder:c786662f4899de16a621e366a485eca5adda4d6a
PLATFORM_IMAGE: ${{ needs.build-all.outputs.core-image }}
JOBS_IMAGE: ${{ needs.build-all.outputs.jobs-image }}
MIGRATIONS_IMAGE: ${{ needs.build-all.outputs.base-image }}
SITE_BUILDER_IMAGE: ${{ needs.build-all.outputs.site-builder-image }}
AWS_REGION: "us-east-1"
COMPOSE_FILES: docker-compose.preview.pr.yml
secrets:
Expand All @@ -155,7 +153,6 @@ jobs:
PLATFORM_IMAGE: "x" # not used
JOBS_IMAGE: "x" # not used
MIGRATIONS_IMAGE: "x" # not used
SITE_BUILDER_IMAGE: "x" # not used
AWS_REGION: "us-east-1"
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/pull-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ on:
MIGRATIONS_IMAGE:
required: true
type: string
SITE_BUILDER_IMAGE:
required: true
type: string
AWS_REGION:
required: true
type: string
Expand Down Expand Up @@ -55,12 +52,10 @@ jobs:
PLATFORM_IMAGE: ${{ inputs.PLATFORM_IMAGE }}
JOBS_IMAGE: ${{ inputs.JOBS_IMAGE }}
MIGRATIONS_IMAGE: ${{ inputs.MIGRATIONS_IMAGE }}
SITE_BUILDER_IMAGE: ${{ inputs.SITE_BUILDER_IMAGE }}
run: |
sed -i "s|image: PLATFORM_IMAGE|image: $PLATFORM_IMAGE|" docker-compose.preview.yml
sed -i "s|image: JOBS_IMAGE|image: $JOBS_IMAGE|" docker-compose.preview.yml
sed -i "s|image: MIGRATIONS_IMAGE|image: $MIGRATIONS_IMAGE|" docker-compose.preview.yml
sed -i "s|image: SITE_BUILDER_IMAGE|image: $SITE_BUILDER_IMAGE|" docker-compose.preview.yml
sed -i "s|DATACITE_REPOSITORY_ID: DATACITE_REPOSITORY_ID|DATACITE_REPOSITORY_ID: ${{ secrets.PREVIEW_DATACITE_REPOSITORY_ID }}|" docker-compose.preview.yml
sed -i "s|DATACITE_PASSWORD: DATACITE_PASSWORD|DATACITE_PASSWORD: ${{ secrets.PREVIEW_DATACITE_PASSWORD }}|" docker-compose.preview.yml
sed -i "s|email someone@example.com|email dev@pubpub.org|" self-host/caddy/Caddyfile
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ storybook-static
./playwright

.local_data

# mock-notify store
.notifications.json
22 changes: 4 additions & 18 deletions core/actions/_lib/interpolationContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,12 @@ export type InterpolationContextBase = {
env: InterpolationEnv
}

export type InterpolationContextWithPub = InterpolationContextBase & {
pub: ReturnType<typeof createPubProxy>
json?: Json
}

export type InterpolationContextWithJson = InterpolationContextBase & {
json: Json
export type InterpolationContext = InterpolationContextBase & {
pub?: ReturnType<typeof createPubProxy>
json?: Json
site?: { base: string }
}

export type InterpolationContextWithBoth = InterpolationContextBase & {
pub: ReturnType<typeof createPubProxy>
json: Json
}

export type InterpolationContext =
| InterpolationContextWithPub
| InterpolationContextWithJson
| InterpolationContextWithBoth

type InterpolationCommunity = Pick<Communities, "id" | "name" | "slug" | "avatar">

type InterpolationStage = Pick<CommunityStage, "id" | "name">
Expand Down Expand Up @@ -107,7 +93,7 @@ type BuildInterpolationContextArgs =
export function buildInterpolationContext(
args: BuildInterpolationContextArgs
): InterpolationContext {
const baseContext: Omit<InterpolationContext, "json" | "pub"> = {
const baseContext: Omit<InterpolationContext, "json" | "pub" | "site"> = {
env: {
PUBPUB_URL: args.env.PUBPUB_URL,
},
Expand Down
202 changes: 1 addition & 201 deletions core/actions/_lib/pubProxy.ts
Original file line number Diff line number Diff line change
@@ -1,201 +1 @@
// import type { ProcessedPub } from "contracts"

// export const createPubProxy = (pub: ProcessedPub, communitySlug: string): any => {
// const valuesMap = new Map<string, ProcessedPub["values"][number]>()

// // these are just so that if you do `$.values`/`$.out`/`$.fields` you can see what fields are available
// const fields: Record<string, undefined> = {}
// const relations: Record<string, undefined> = {}

// for (const value of pub.values) {
// fields[value.fieldSlug] = undefined
// fields[value.fieldSlug.replace(`${communitySlug}:`, "")] = undefined
// if (value.relatedPub) {
// relations[value.fieldSlug] = undefined
// relations[value.fieldSlug.replace(`${communitySlug}:`, "")] = undefined
// }
// valuesMap.set(value.fieldSlug, value)
// }

// const pubWithAdditionalFields = { ...pub, fields: undefined, out: relations }

// return new Proxy(pubWithAdditionalFields, {
// get(target, prop) {
// const propStr = String(prop)
// const _lowerProp = propStr.toLowerCase()

// if (prop === "fields") {
// return new Proxy(fields, {
// get(_, fieldSlug: string) {
// return fields[fieldSlug] || fields[fieldSlug.toLowerCase()]
// },
// })
// }
// if (prop === "values") {
// return new Proxy(fields, {
// get(_, fieldSlug: string) {
// const lowerFieldSlug = fieldSlug.toLowerCase()
// const val =
// valuesMap.get(`${communitySlug}:${fieldSlug}`) ??
// valuesMap.get(fieldSlug) ??
// valuesMap.get(`${communitySlug}:${lowerFieldSlug}`) ??
// valuesMap.get(lowerFieldSlug)
// return val?.value
// },
// })
// }

// if (prop === "out") {
// return new Proxy(relations, {
// get(_, fieldSlug: string) {
// if (typeof fieldSlug !== "string") {
// return undefined
// }

// if (fieldSlug === "out") {
// return relations
// }

// const lowerFieldSlug = fieldSlug.toLowerCase()

// const val =
// valuesMap.get(`${communitySlug}:${fieldSlug}`) ??
// valuesMap.get(fieldSlug) ??
// valuesMap.get(`${communitySlug}:${lowerFieldSlug}`) ??
// valuesMap.get(lowerFieldSlug)
// if (val && "relatedPub" in val && val.relatedPub) {
// return createPubProxy(val.relatedPub, communitySlug)
// }
// return undefined
// },
// })
// }

// if (prop === "in") {
// return new Proxy(relations, {
// get(_, fieldSlug: string) {
// const _lowerFieldSlug = fieldSlug.toLowerCase()
// // For "in", we look for pubs that point to this one via fieldSlug
// // This proxy doesn't currently support "in" metadata easily as it's not pre-loaded in valuesMap in the same way.
// // However, if we had it, we'd look it up here.
// return undefined
// },
// })
// }

// return target[prop as keyof typeof target]
// },
// })
// }

import type { ProcessedPub } from "contracts"

// properties that should never be forwarded through the proxy
const BLOCKED_PROPS = new Set([
"then",
"catch",
"finally",
"constructor",
"__proto__",
"prototype",
"$$typeof",
"toJSON",
"valueOf",
"toString",
"hasOwnProperty",
"isPrototypeOf",
"propertyIsEnumerable",
])

const isBlockedProp = (prop: string | symbol): boolean => {
if (typeof prop === "symbol") return true
return BLOCKED_PROPS.has(prop)
}

// creates a proxy that allows case-insensitive lookup but also returns the full object when iterated
const createLookupProxy = <T>(
data: Record<string, T>,
communitySlug: string
): Record<string, T> => {
return new Proxy(data, {
get(target, prop) {
if (isBlockedProp(prop)) return undefined
const propStr = String(prop)
// direct match
if (propStr in target) return target[propStr]
// try with community prefix
const prefixed = `${communitySlug}:${propStr}`
if (prefixed in target) return target[prefixed]
// try lowercase
const lower = propStr.toLowerCase()
if (lower in target) return target[lower]
const prefixedLower = `${communitySlug}:${lower}`
if (prefixedLower in target) return target[prefixedLower]
return undefined
},
has(target, prop) {
if (isBlockedProp(prop)) return false
return prop in target
},
ownKeys(target) {
return Reflect.ownKeys(target)
},
getOwnPropertyDescriptor(target, prop) {
return Object.getOwnPropertyDescriptor(target, prop)
},
})
}

export const createPubProxy = (
pub: ProcessedPub,
communitySlug: string
): Record<string, unknown> => {
// build plain objects for all lookups
const fields: Record<string, true> = {}
const values: Record<string, unknown> = {}
const out: Record<string, Record<string, unknown>> = {}

for (const v of pub.values) {
const shortSlug = v.fieldSlug.replace(`${communitySlug}:`, "")
// use short slug as primary key to avoid duplicates
fields[shortSlug] = true
values[shortSlug] = v.value

if (v.relatedPub) {
out[shortSlug] = createPubProxy(v.relatedPub, communitySlug)
}
}

const fieldsProxy = createLookupProxy(fields, communitySlug)
const valuesProxy = createLookupProxy(values, communitySlug)
const outProxy = createLookupProxy(out, communitySlug)

// build the base object with all pub properties except values (which we override)
const base: Record<string, unknown> = {}
for (const key of Object.keys(pub)) {
if (key === "values") continue
base[key] = pub[key as keyof ProcessedPub]
}

base.fields = fieldsProxy
base.values = valuesProxy
base.out = outProxy
base.in = {} // not implemented yet

return new Proxy(base, {
get(target, prop) {
if (isBlockedProp(prop)) return undefined
return target[prop as string]
},
has(target, prop) {
if (isBlockedProp(prop)) return false
return prop in target
},
ownKeys(target) {
return Reflect.ownKeys(target)
},
getOwnPropertyDescriptor(target, prop) {
return Object.getOwnPropertyDescriptor(target, prop)
},
})
}
export { createPubProxy, type IncomingRelations } from "contracts"
1 change: 1 addition & 0 deletions core/actions/_lib/resolveAutomationInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export async function resolveAutomationInput(
withRelatedPubs: true,
withStage: false,
withValues: true,
withIncomingRelations: true,
depth: 3,
limit: 1,
customFilter: (eb) => applyJsonataFilter(eb, compiled, { communitySlug }),
Expand Down
1 change: 1 addition & 0 deletions core/actions/_lib/runAutomation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ async function loadAutomationContext(args: {
withRelatedPubs: true,
withStage: false,
withValues: true,
withIncomingRelations: true,
depth: 3,
}
)
Expand Down
Loading
Loading