Skip to content

Commit

Permalink
Merge pull request GEOLYTIX#1672 from GEOLYTIX/patch
Browse files Browse the repository at this point in the history
Patch v14.12.2
  • Loading branch information
RobAndrewHurst authored Nov 1, 2024
2 parents 69c6c44 + 5c713c0 commit 3067e88
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name: "CodeQL"

on:
push:
branches: [ "main" ]
branches: [ "main", "major", "minor", "patch" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
branches: [ "main", "major", "minor", "patch" ]
schedule:
- cron: '40 1 * * 2'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Deploy static content to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
branches: [ "main" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: ESLint

on:
push:
branches: [ main ]
branches: [ "main", "major", "minor", "patch" ]
pull_request:
branches: [ main ]
branches: [ "main", "major", "minor", "patch" ]

jobs:
eslint:
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/patch-minor-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: patch-merge
on:
push:
branches:
- 'patch'

permissions:
contents: write
pull-requests: write

jobs:
merge-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Merge patch -> minor
uses: devmasx/merge-branch@master
with:
type: now
target_branch: minor
message: Merge patch into minor
github_token: ${{ secrets.PAT_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Codi unit tests

on:
push:
branches: [ main ]
branches: [ "main", "major", "minor", "patch" ]
pull_request:
branches: [ main ]
branches: [ "main", "major", "minor", "patch" ]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**v4.12.1**
**v4.12.2**

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![Codi Unit Tests](https://github.com/GEOLYTIX/xyz/actions/workflows/unit_tests.yml/badge.svg)
Expand Down
4 changes: 2 additions & 2 deletions lib/mapp.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ if (window.ol === undefined) {
self.mapp = {
ol: _ol,

version: '4.12.1',
version: '4.12.2',

hash: 'd18842e399cba41278b14e6658d2706a692f9b19',
hash: '52558fa8bbd8752e4f27036c7ca95a7f3426a205',

host: document.head?.dataset?.dir || '',

Expand Down
1 change: 1 addition & 0 deletions lib/ui/Dataview.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default async function Dataview(_this) {
_this.queryparams = {
..._this.layer?.mapview?.locale?.queryparams,
..._this.layer?.queryparams,
..._this.location?.layer?.queryparams,
..._this.queryparams,
}

Expand Down
2 changes: 1 addition & 1 deletion lib/ui/layers/listview.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default function (params) {
group.meta = mapp.utils.html.node`<div class="meta">`

group.drawer = mapp.ui.elements.drawer({
data_id: `layer-drawer`,
data_id: layer.group,
class: `layer-group ${layer.groupClassList || ''}`,
header: mapp.utils.html`
<h2>${layer.group}</h2>
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/layers/view.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default function layerView(layer) {
const drawerClass = `layer-view raised ${layer.classList || ''} ${content.length ? '' : 'empty'}`

layer.drawer = mapp.ui.elements.drawer({
data_id: `layer-drawer`,
data_id: layer.key,
class: drawerClass,
header,
content
Expand Down Expand Up @@ -242,7 +242,7 @@ function changeEnd(layer) {
layer.zoomBtn.style.display = 'block'

// Collapse drawer and disable layer.view.
layer.view.querySelector('[data-id=layer-drawer]').classList.remove('expanded')
layer.view.querySelector('.layer-view.drawer').classList.remove('expanded')

// Disable layer display toggle.
layer.displayToggle.classList.add('disabled')
Expand Down
51 changes: 38 additions & 13 deletions mod/provider/cloudfront.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,52 @@
/**
## /provider/cloudfront
The cloudfront provider module exports a method to fetch resources from an AWS cloudfront service.
@requires fs
@requires path
@requires module:/utils/logger
@requires @aws-sdk/cloudfront-signer
@module /provider/cloudfront
*/

const { readFileSync } = require('fs')

const { join } = require('path')

const { getSignedUrl } = require('@aws-sdk/cloudfront-signer');

const logger = require('../utils/logger')

const nodeFetch = require('node-fetch')
/**
@function cloudfront
@async
@description
The method creates a signed URL for a cloudfront resource, fetches the resource and returns the fetched resource.
A buffer is returned with the ref.params.buffer flag.
module.exports = async ref => {
JSON is returned if the URL path matches the .json file ending to fetch a JSON resource from the cloudfront service.
The fetch response will be parsed as text by default.
@param {Object|string} ref Reference object or URL string.
@property {Object} [ref.params] Optional parameters for the request.
@property {string} [params.url] Cloudfront resource URL.
@property {boolean} [params.signedURL] Return a signedURL only.
@property {boolean} [params.buffer] Return a buffer from the fetch.
@returns {Promise<String|JSON|Buffer|Error>} The method resolves to either JSON, Text, or Buffer dependent ref.params.
*/
module.exports = async function cloudfront(ref) {

try {

// Subtitutes {*} with process.env.SRC_* key values.
// Substitutes {*} with process.env.SRC_* key values.
const url = (ref.params?.url || ref).replace(/{(?!{)(.*?)}/g,
matched => process.env[`SRC_${matched.replace(/(^{)|(}$)/g, '')}`])

const date = new Date(Date.now())

date.setDate(date.getDate() + 1);

const signedURL = getSignedUrl({
Expand All @@ -32,13 +58,12 @@ module.exports = async ref => {

// Return signedURL only from request.
if (ref.params?.signedURL) {

return signedURL;
}

const response = await nodeFetch(signedURL)

logger(`${response.status} - ${url}`,'cloudfront')
const response = await fetch(signedURL)
logger(`${response.status} - ${url}`, 'cloudfront')

if (response.status >= 300) return new Error(`${response.status} ${ref}`)

Expand All @@ -48,8 +73,8 @@ module.exports = async ref => {

return await response.text()

} catch(err) {
} catch (err) {

console.error(err)
}

}
}
2 changes: 2 additions & 0 deletions mod/workspace/_workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ function roles(req, res) {
@description
The workspace/test method which is only available to user with admin credentials requests all locales in workspace.
The cached workspace will be flushed for the test method.
Requesting all locales should add any additional templates to the workspace.
The test method will iterate over all workspace.templates and get from the getTemplate method to check whether any errors are logged on a template in regards to its src parameter.
Expand Down
5 changes: 4 additions & 1 deletion mod/workspace/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const getFrom = require('../provider/getFrom')

const merge = require('../utils/merge')

// Assign default age in ms.
process.env.WORKSPACE_AGE ??= 3600000

let cache = null
Expand All @@ -28,7 +29,9 @@ const logger = require('../utils/logger')
@description
The method checks whether the module scope variable cache has been populated.
The age of the cached timestamp is checked against the WORKSPACE_AGE environment variable.
The timestamp set by cacheWorkspace is checked against the current time. The [workspace] cache will be invalidated if the difference exceeds the WORKSPACE_AGE environment variable.
Setting the WORKSPACE_AGE to 0 is not recommended as this could cause the cache to be flushed while a request is passed through the XYZ API. A layer query processed by the [Query API module]{@link module:/query~layerQuery} will request the layer and associated locale which could be defined in remote templates. Each request to the [Workspace API getTemplate]{@link module:/workspace/getTemplate~getTemplate} method for the locale, layer, and query templates will call the checkWorkspaceCache method which will cause the workspace to be flushed and templates previously cached from their src no longer available.
The cacheWorkspace method is called if the cache is invalid.
Expand Down
2 changes: 1 addition & 1 deletion mod/workspace/getTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const envReplace = require('../utils/envReplace')
@async
@description
The workspace will be requested from the workspace/cache module.
The workspace will checked and cached by the [Workspace API checkWorkspaceCache]{@link module:/workspace/cache~checkWorkspaceCache} method.
A template object matching the template_key param in the workspace.templates{} object will be returned from the getTemplate method.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xyz",
"version": "v4.12.1",
"version": "v4.12.2",
"repository": {
"type": "git",
"url": "https://github.com/geolytix/xyz"
Expand Down Expand Up @@ -39,4 +39,4 @@
"express": "^4.18.3",
"uhtml": "^3.1.0"
}
}
}
2 changes: 1 addition & 1 deletion public/views/_default.html
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@
// Show the tabview if not already visible.
if (tabview.classList.contains('desktop-display-none')) {
tabview.classList.remove('desktop-display-none');
document.body.style.gridTemplateRows = 'auto 10px 50px';
document.body.style.gridTemplateRows = 'auto 10px 200px';
}
},
removeLastTab: () => {
Expand Down

0 comments on commit 3067e88

Please sign in to comment.