diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 1764a860e..43db735f7 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -43,7 +43,7 @@ jobs: echo "Package.json version: v${{ steps.package-version.outputs.packageVersion }}" test "${{ steps.tag-version.outputs.tagVersion }}" == "v${{ steps.package-version.outputs.packageVersion }}" - name: Notify release in progress in Slack - uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 + uses: slackapi/slack-github-action@af78098f536edbc4de71162a307590698245be95 # v3.0.1 with: method: chat.postMessage token: ${{ secrets.SLACK_BOT_TOKEN }} @@ -103,7 +103,7 @@ jobs: needs: [create-release] runs-on: ubuntu-latest steps: - - uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 + - uses: slackapi/slack-github-action@af78098f536edbc4de71162a307590698245be95 # v3.0.1 with: method: chat.postMessage token: ${{ secrets.SLACK_BOT_TOKEN }} @@ -144,7 +144,7 @@ jobs: needs: [create-release] runs-on: ubuntu-latest steps: - - uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 + - uses: slackapi/slack-github-action@af78098f536edbc4de71162a307590698245be95 # v3.0.1 with: method: chat.postMessage token: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/.github/workflows/notify-release-published.yaml b/.github/workflows/notify-release-published.yaml index b8397eafb..8245bc63f 100644 --- a/.github/workflows/notify-release-published.yaml +++ b/.github/workflows/notify-release-published.yaml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Send Slack release published notification - uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 + uses: slackapi/slack-github-action@af78098f536edbc4de71162a307590698245be95 # v3.0.1 with: method: chat.postMessage token: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/.github/workflows/publish-docker.yaml b/.github/workflows/publish-docker.yaml index e031290f3..dad2e94ad 100644 --- a/.github/workflows/publish-docker.yaml +++ b/.github/workflows/publish-docker.yaml @@ -23,7 +23,7 @@ jobs: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Setup Docker metadata id: meta - uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 + uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 with: images: harperfast/harper - name: Login to Docker Hub @@ -61,14 +61,14 @@ jobs: docker-image-tag: ${{ steps.meta.outputs.version }} steps: - name: Download digests - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: path: /tmp/digests pattern: digest-* merge-multiple: true - name: Setup Docker metadata id: meta - uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 + uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 with: images: harperfast/harper tags: | @@ -96,7 +96,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Send Slack published notification - uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 + uses: slackapi/slack-github-action@af78098f536edbc4de71162a307590698245be95 # v3.0.1 with: method: chat.postMessage token: ${{ secrets.SLACK_BOT_TOKEN }} @@ -137,7 +137,7 @@ jobs: needs: [merge] runs-on: ubuntu-latest steps: - - uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 + - uses: slackapi/slack-github-action@af78098f536edbc4de71162a307590698245be95 # v3.0.1 with: method: chat.postMessage token: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/.github/workflows/publish-npm.yaml b/.github/workflows/publish-npm.yaml index e731b4ded..f33d04dcf 100644 --- a/.github/workflows/publish-npm.yaml +++ b/.github/workflows/publish-npm.yaml @@ -97,7 +97,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Send Slack published notification - uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 + uses: slackapi/slack-github-action@af78098f536edbc4de71162a307590698245be95 # v3.0.1 with: method: chat.postMessage token: ${{ secrets.SLACK_BOT_TOKEN }} @@ -144,7 +144,7 @@ jobs: - publish-harper-npm-package runs-on: ubuntu-latest steps: - - uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 + - uses: slackapi/slack-github-action@af78098f536edbc4de71162a307590698245be95 # v3.0.1 with: method: chat.postMessage token: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/resources/Table.ts b/resources/Table.ts index 7bfe04ea8..aabd94521 100644 --- a/resources/Table.ts +++ b/resources/Table.ts @@ -2262,7 +2262,9 @@ export function makeTable(options) { return (entryA, entryB) => { const a = getAttributeValue(entryA, order.attribute, context); const b = getAttributeValue(entryB, order.attribute, context); - const diff = descending ? compareKeys(b, a) : compareKeys(a, b); + const diff = descending + ? compareKeys(convertToComparableKeys(b), convertToComparableKeys(a)) + : compareKeys(convertToComparableKeys(a), convertToComparableKeys(b)); if (diff === 0) return nextComparator?.(entryA, entryB) || 0; return diff; }; @@ -4572,3 +4574,12 @@ function hasOtherProcesses(store) { return +line.match(/\d+/)?.[0] != pid; }); } +function convertToComparableKeys(a) { + if (a instanceof Date) { + return a.getTime(); + } + if (Array.isArray(a)) { + return a.map(convertToComparableKeys); + } + return a; +} diff --git a/unitTests/resources/query.test.js b/unitTests/resources/query.test.js index 7749427e1..f7569d5e7 100644 --- a/unitTests/resources/query.test.js +++ b/unitTests/resources/query.test.js @@ -54,6 +54,7 @@ describe('Querying through Resource API', () => { { name: 'name', type: 'String' }, ], }, + { name: 'createdAt', type: 'Date', assignCreatedTime: true }, ], }); QueryTable.setComputedAttribute('computed', (instance) => instance.name + ' computed'); @@ -148,6 +149,7 @@ describe('Querying through Resource API', () => { notIndexed: 'not indexed ' + i, nestedData: i > 0 ? { id: 'nested-' + i, name: 'nested name ' + i } : null, }); + await new Promise((resolve) => setTimeout(resolve, 1)); // leave one ms so createdAt is different } await last; // rewrite one of them to ensure the prototype doesn't get messed up @@ -904,6 +906,18 @@ describe('Querying through Resource API', () => { assert.equal(results[0].id, 'id-98'); assert.equal(results[1].id, 'id-93'); }); + it('Query data in a table with and sort on createdAt', async function () { + let results = []; + for await (let record of QueryTable.search({ + conditions: [{ attribute: 'relatedId', value: 3 }], + sort: { attribute: 'createdAt', descending: true }, + })) { + results.push(record); + } + assert.equal(results.length, 20); + assert.equal(results[0].id, 'id-98'); + assert.equal(results[1].id, 'id-93'); + }); it('Query data in a table with narrow constraint with multiple sorting on different properties', async function () { let results = []; for await (let record of QueryTable.search({