Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
293ffc8
ci(deps): up node version
Apr 8, 2024
cf82beb
test(events): add test for non existing event emit
Apr 8, 2024
2cb8ffe
feat(helpers): add type assertion to isUuid
Apr 8, 2024
c2fbe35
chore: simplify and make ts more strict
Apr 8, 2024
265aa74
chore: bump version
Apr 8, 2024
19ebe14
build: make package an ESM module
nandi95 Apr 9, 2024
9995ec1
chore: code style fixes
nandi95 Apr 10, 2024
242279c
chore: update and add dependencies
nandi95 Apr 10, 2024
586552b
chore: made rollup config into ts file
nandi95 Apr 10, 2024
54b16c1
ci: add provenance
nandi95 Apr 10, 2024
bcae937
docs: small comment changes
nandi95 Apr 10, 2024
ddd0372
build: work-in-progress export helpers separately and ease access
nandi95 Apr 10, 2024
a21b8be
style: adjust eslint rule
nandi95 Apr 10, 2024
7fe5101
test: use response from global namespace
nandi95 Apr 10, 2024
c9f3e83
chore: made release config a module
nandi95 Apr 10, 2024
f26f6f8
docs: update to the correct api docs link
nandi95 Apr 10, 2024
117d23c
test(api-calls): update test for new node versions
nandi95 Apr 11, 2024
ca26449
test: remove test with 100 status
nandi95 Apr 12, 2024
e9892c2
test: remove fetch polyfill for node
nandi95 Apr 12, 2024
ad1aea9
chore: add types to default export
nandi95 Sep 27, 2024
e951182
test(helpers): started testing for `poll`
nandi95 Sep 27, 2024
b222a7d
ci: update node version
nandi95 Sep 27, 2024
d2531e3
perf: use built in utility types
nandi95 Sep 27, 2024
321c502
feat: add utility type
nandi95 Sep 27, 2024
c50fbc5
test(services): fix error expectation for node 22
nandi95 Sep 27, 2024
e077bad
perf(helpers): remove unnecessary function overrides
nandi95 Sep 27, 2024
5dbb9cf
feat(helpers): add `poll` function
nandi95 Oct 3, 2024
fe8f488
chore: remove duplicate type export
nandi95 Oct 3, 2024
001259b
test(api-calls): start debugging equality issue
nandi95 Oct 3, 2024
5d788d9
test: change from jest to vitest
nandi95 Nov 14, 2024
8a57bf9
test: add edge runtime for testing
nandi95 Nov 14, 2024
43868f2
test: remove unused jest config
nandi95 Nov 14, 2024
32db7a1
ci: update action versions
nandi95 May 25, 2025
ce9b7f1
style: upgrade eslint
nandi95 May 25, 2025
c400047
fix: import assertion issue
nandi95 Sep 22, 2025
54ddc67
chore(deps): updated packages
nandi95 Sep 22, 2025
ffcf405
chore(deps): update action versions
nandi95 Sep 22, 2025
54ee753
docs(helpers): document poll fn
nandi95 Sep 22, 2025
eee24e7
fix(helpers): fix type issue
nandi95 Sep 22, 2025
cb75d93
build: ignore output
nandi95 Sep 22, 2025
df79733
test(ancestry-collection): ensure the children are model collections
nandi95 Sep 22, 2025
80da489
style: ignore links file
nandi95 Sep 22, 2025
ba6a910
chore: upgrade eslint
nandi95 Sep 22, 2025
3332403
feat(collection): add missing array functions
nandi95 Sep 22, 2025
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
68 changes: 34 additions & 34 deletions .commitlintrc.js β†’ .commitlintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
/**
* @type {import('@commitlint/types').UserConfig}
*/
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'scope-enum': [
2,
'always',
[
'attributes', // guarding and casting can also go under attributes
'global-config',
'exception',
'events',
'services',
'helpers',
'collection',
'model',
'model-collection',
'ancestry-collection',
'paginator',
'factory',
'query-builder',
'timestamps', // soft-deletes can also go under timestamps
'relations',
'api-calls',
'deps',
'deps-dev',
'internal' // things that are not meant to be used outside the package
]
],
}
};
/**
* @type {import('@commitlint/types').UserConfig}
*/
module.exports = {
extends: ['@commitlint/config-conventional'],

rules: {
'scope-enum': [
2,
'always',
[
'attributes', // guarding and casting can also go under attributes
'global-config',
'exception',
'events',
'services',
'helpers',
'collection',
'model',
'model-collection',
'ancestry-collection',
'paginator',
'factory',
'query-builder',
'timestamps', // soft-deletes can also go under timestamps
'relations',
'api-calls',
'deps',
'deps-dev',
'internal' // things that are not meant to be used outside the package
]
],
}
};
103 changes: 0 additions & 103 deletions .eslintrc.js

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
cache: 'npm'
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
cache: 'npm'
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
cache: 'npm'
- name: Install dependencies
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,23 @@ jobs:
publish:
timeout-minutes: 10
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Build library
run: npm run build
- name: Publish library
run: npm publish --access public
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/setup-node@v3
- uses: actions/setup-node@v5
with:
registry-url: https://npm.pkg.github.com/
- run: npm publish --access public
Expand Down
50 changes: 33 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
- '**/tsconfig.json'
- 'tests/**/*.ts'
- 'src/**/*.ts'
- 'jest.config.ts'
- 'package-lock.json'
branches:
- main
Expand All @@ -21,37 +20,54 @@ jobs:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
steps:
# subsequent calls to this action will use already downloaded code from the workspace
- uses: actions/checkout@v3
jest-browser:
- uses: actions/checkout@v5
test-browser:
needs: setup-test
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 'lts/*'
cache: 'npm'
node-version: 'latest'
- name: Install dependencies
run: npm ci --ignore-scripts
run: npm ci
- name: Run tests on jsdom
run: npx jest --selectProjects=jsdom
jest-node:
run: npm run test -- --environment=jsdom
test-node:
needs: setup-test
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
matrix:
# current and active LTS
node: [ 18, 20 ]
node: ['lts/*', 'current']
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests on node ${{ matrix.node }}
run: npm run test
test-edge:
needs: setup-test
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
matrix:
node: ['lts/*', 'current']
fail-fast: false
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Run tests on node v${{ matrix.node }}
run: npx jest --selectProjects=node
run: npm ci
- name: Run tests on node ${{ matrix.node }}
run: npm run test -- --environment edge-runtime
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ index.*.*js*
array.*.*js*
string.*.*js*
types
/Support
*.tgz
tslib.es6-*

# in case gh-pages manually managed
index.html
Expand Down
6 changes: 6 additions & 0 deletions build.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"include": [
"src/*.ts"
]
}
2 changes: 1 addition & 1 deletion docs/.vuepress/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const sidebar: SidebarConfig = [
]

const navbar: NavbarConfig = [
{ text: 'API', link: 'https://upfrontjs.github.io/framework', target:'_blank' }
{ text: 'API', link: 'https://api.upfrontjs.com/framework', target:'_blank' }
]

export default {
Expand Down
33 changes: 33 additions & 0 deletions docs/helpers/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,39 @@ value(
); // 2
```

#### poll

The `poll` method repeatedly executes a promise function until a specified condition is met. It's useful for polling operations where you need to wait for a resource to become available or reach a desired state. The function takes 3 arguments:
- `fn` - The function returning a promise to be called repeatedly
- `wait` (default: 0) - The wait time between attempts in milliseconds. If 0, it will not wait between attempts. If a function, it will be called with the result and attempt count.
- `until` - The condition to stop polling. If a Date, polling stops when that time is reached. If a function, it receives the result and attempt count and should return true to stop.

```ts
import { poll } from '@upfrontjs/framework';

// Poll an API endpoint every 1000ms until a specific condition is met
const result = await poll(
() => fetch('/api/status').then(r => r.json()),
1000,
(data) => data.status === 'complete'
);

// Poll with dynamic wait time based on attempts
const result = await poll(
() => checkResource(),
(result, attempts) => Math.min(1000 * attempts, 10000), // exponential backoff with cap
(result) => result.ready
);

// Poll until a specific time
const timeoutDate = new Date(Date.now() + 30000); // 30 seconds from now
const result = await poll(
() => performCheck(),
500,
timeoutDate
);
```

#### dataGet

The `dataGet` is a helper method to safely access any path within an object or array. If the path does not exist, it will return the default value (default: `undefined`). Optionally the path may include a wildcard `*` to match array elements.
Expand Down
4 changes: 2 additions & 2 deletions docs/testing/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import User from '@/Models'
const config = new GlobalConfig;

describe('customAjaxMethod()', () => {
const mockFunc = jest.fn();
const mockFunc = vi.fn();
const user = new User;
config.set('api', {
handle: mockFunc
Expand All @@ -43,7 +43,7 @@ import User from '@/Models/User'
const config: GlobalConfig<MyConfig extends Configuration> = new GlobalConfig;

describe('customAjaxMethod()', () => {
const mockFunc = jest.fn();
const mockFunc = vi.fn();
const user = new User;
config.set('api', {
handle: mockFunc
Expand Down
Loading
Loading