Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
Release-As: 0.1.0
  • Loading branch information
k3nsei committed Aug 11, 2024
0 parents commit 8dced76
Show file tree
Hide file tree
Showing 51 changed files with 21,651 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: k3nsei
27 changes: 27 additions & 0 deletions .github/actions/install-npm-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Install Dependencies
description: Install node.js and install npm dependencies

inputs:
node-version:
description: 'Which version of Node.js to install'
required: false
default: 'lts/*'
registry-url:
description: 'Which NPM registry url to use'
required: false
default: 'https://registry.npmjs.org'

runs:
using: composite
steps:
- name: Setup Node.js and NPM
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
registry-url: ${{ inputs.registry-url }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'

- name: Install NPM dependencies
shell: bash
run: npm ci
26 changes: 26 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: pr

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
branches: [main]

permissions:
contents: read

jobs:
pr:
name: Run build and unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-npm-deps

- name: Build
run: npx --no -- ng build ngx-signal-store-query
70 changes: 70 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: release-please

on:
push:
branches: [main]
workflow_dispatch:
inputs:
reason:
description: Why was the workflow triggered manually?
required: true
type: string

permissions:
contents: write
pull-requests: write
id-token: write

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- name: Prepare release PR or move on with release when PR was accepted
id: release
uses: google-github-actions/release-please-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
package-name: '@ngx-signal-store-query/core'
extra-files: |
LICENSE
README.md
- name: Checkout repository
if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v4

- name: Setup NodeJS
if: ${{ steps.release.outputs.release_created }}
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: '**/package-lock.json'

- name: Install NPM dependencies
if: ${{ steps.release.outputs.release_created }}
shell: bash
run: npm ci

- name: Build
if: ${{ steps.release.outputs.release_created }}
shell: bash
run: npx --no -- ng build ngx-signal-store-query

- name: Copy extra files
if: ${{ steps.release.outputs.release_created }}
shell: bash
run: |
cp LICENSE dist/libs/ngx-signal-store-query/LICENSE
cp README.md dist/libs/ngx-signal-store-query/README.md
- name: Publish
if: ${{ steps.release.outputs.release_created }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
shell: bash
run: |
cd dist/libs/ngx-signal-store-query
npm publish --provenance --access public
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db
5 changes: 5 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

[ -n "$CI" ] && exit 0

npx --no -- commitlint --edit "${1}"
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

[ -n "$CI" ] && exit 0

npx --no -- lint-staged --allow-empty
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.angular
/.husky/_
/coverage
/dist
/tmp
/out-tsc
/bazel-out
4 changes: 4 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
"recommendations": ["angular.ng-template"]
}
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: start",
"url": "http://localhost:4200/"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: test",
"url": "http://localhost:9876/debug.html"
}
]
}
42 changes: 42 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "start",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
},
{
"type": "npm",
"script": "test",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
}
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Piotr Stępniewski

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# ngx-signal-store-query

Signal Store feature that bridges with Angular Query

## Simple Example

#### Create Store

```typescript
import { signalStore, withState } from '@ngrx/signals';
import { withQuery } from '@ngx-signal-store-query/core';
import { lastValueFrom } from 'rxjs';

import { ApiService } from './api.service';

export const ExampleStore = signalStore(
withState({ categoryId: 1 }),
withQuery('example', (store) => {
const apiService = inject(ApiService);

return () => {
const categoryId = store.categoryId();

return {
enabled: !!categoryId,
queryKey: ['category', { id: categoryId }],
queryFn: () =>
lastValueFrom(apiService.getCategory$(categoryId)).catch((error) => {
console.error(error);

return null;
}),
};
};
}),
);
```

#### Use it in component

```typescript
import { JsonPipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';

import { ExampleStore } from './example.store.ts';

@Component({
standalone: true,
selector: 'app-example',
template: `
<pre>
Loading: {{ store.exampleQuery().isLoading() }}
Fetching: {{ store.exampleQuery().isFetching() }}
Data:
{{ store.exampleQuery().data() | json }}
</pre>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [JsonPipe],
})
export class ExampleComponent {
public readonly store = inject(ExampleStore);
}
```
Loading

0 comments on commit 8dced76

Please sign in to comment.