Skip to content

Tasks #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 5 additions & 1 deletion admin/days-worked.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ Budget: `3000-(20*80)=1400`

# F2 (Solid backend for remoteStorage.js) 4k
* Yashar worked on this for at least a day or 5-10 I think?
* I worked on this for 2 hours today (16 January)
* Michiel worked on this for 2 hours today (16 January)

# general work by Michiel (have to see if/how we can use this for milestone claims)
* Friday 19 Jan: 6 hours on Tasks module
* Monday 22 Jan: 3 hours on [Bookmarks/Contacts demo video?], 3 hours liaising with Solid CG/Team
8 changes: 8 additions & 0 deletions tasks/soukai/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# don't ever lint node_modules
node_modules

# don't lint build output (make sure it's set to your correct build folder name)
lib

# don't lint nyc coverage output
coverage
10 changes: 10 additions & 0 deletions tasks/soukai/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "jest"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended"
]
}
5 changes: 5 additions & 0 deletions tasks/soukai/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 120,
"trailingComma": "all",
"singleQuote": true
}
7 changes: 7 additions & 0 deletions tasks/soukai/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2022 Hebert Cisco

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.
86 changes: 86 additions & 0 deletions tasks/soukai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<p align="center">
<img width="100px" src="https://raw.githubusercontent.com/hebertcisco/ts-npm-package-boilerplate/main/.github/images/favicon512x512-npm.png" align="center" alt=":package: ts-npm-package-boilerplate" />
<h2 align="center">:package: ts-npm-package-boilerplate</h2>
<p align="center">TypeScript NPM Module Boilerplate</p>
<p align="center">
<a href="https://github.com/hebertcisco/ts-npm-package-boilerplate/issues">
<img alt="Issues" src="https://img.shields.io/github/issues/hebertcisco/ts-npm-package-boilerplate?style=flat&color=336791" />
</a>
<a href="https://github.com/hebertcisco/ts-npm-package-boilerplate/pulls">
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/hebertcisco/ts-npm-package-boilerplate?style=flat&color=336791" />
</a>
<a href="https://github.com/hebertcisco/ts-npm-package-boilerplate">
<img alt="GitHub Downloads" src="https://img.shields.io/npm/dw/ts-npm-package-boilerplate?style=flat&color=336791" />
</a>
<a href="https://github.com/hebertcisco/ts-npm-package-boilerplate">
<img alt="GitHub Total Downloads" src="https://img.shields.io/npm/dt/ts-npm-package-boilerplate?color=336791&label=Total%20downloads" />
</a>
<a href="https://github.com/hebertcisco/ts-npm-package-boilerplate">
<img alt="GitHub release" src="https://img.shields.io/github/release/hebertcisco/ts-npm-package-boilerplate.svg?style=flat&color=336791" />
</a>
<br />
<br />
<a href="https://github.com/hebertcisco/ts-npm-package-boilerplate/issues/new/choose">Report Bug</a>
<a href="https://github.com/hebertcisco/ts-npm-package-boilerplate/issues/new/choose">Request Feature</a>
</p>
<h3 align="center">Systems on which it has been tested:</h3>
<p align="center">
<a href="https://www.apple.com/br/macos/">
<img alt="Macos" src="https://img.shields.io/badge/mac%20os-000000?style=for-the-badge&logo=apple&logoColor=white&style=flat" />
</a>
<a href="https://ubuntu.com/download">
<img alt="Ubuntu" src="https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge&logo=ubuntu&logoColor=white&style=flat" />
</a>
<a href="https://www.microsoft.com/pt-br/windows/">
<img alt="Windows" src="https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white&style=flat" />
</a>
</p>
<p align="center">Did you like the project? Please, considerate <a href="https://www.buymeacoffee.com/hebertcisco">a donation</a> to help improve!</p>

<p align="center"><strong>TypeScript NPM Module Boilerplate</strong>✨</p>

[![codecov](https://codecov.io/gh/hebertcisco/ts-npm-package-boilerplate/branch/main/graph/badge.svg?token=Q9fr548J0D)](https://codecov.io/gh/hebertcisco/ts-npm-package-boilerplate)

# Getting started

## Installation

> Clone this repository: `git clone https://github.com/hebertcisco/ts-npm-package-boilerplate`

### Open the directory and run the script line:

```bash
cd ts-npm-package-boilerplate
```
```bash
npm i # or yarn
```
```bash
rm -rf .git && git init && git add . && git commit -m "Initial commit" #Optional
```
Or create use the button "Use this template"

Edit the Icon on Figma:

<a href="https://www.figma.com/file/vpevGX3j9tmtW8OyLQ9eUm/ts-npm-package-boilerplate-icon?node-id=0%3A1">
<img alt="Figma Icon" src="https://raw.githubusercontent.com/hebertcisco/ts-npm-package-boilerplate/main/.github/images/figma-badge.png"/>
</a>

## 🤝 Contributing

Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](issues).

## Show your support

Give a ⭐️ if this project helped you!

Or buy me a coffee 🙌🏾

<a href="https://www.buymeacoffee.com/hebertcisco">
<img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=hebertcisco&button_colour=FFDD00&font_colour=000000&font_family=Inter&outline_colour=000000&coffee_colour=ffffff" />
</a>

## 📝 License

Copyright © 2022 [Hebert F Barros](https://github.com/hebertcisco).<br />
This project is [MIT](LICENSE) licensed.
21 changes: 21 additions & 0 deletions tasks/soukai/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Security Policy

## Supported Versions

Use this section to tell people about which versions of your project are
currently being supported with security updates.

| Version | Supported |
| ------- | ------------------ |
| 5.1.x | :white_check_mark: |
| 5.0.x | :x: |
| 4.0.x | :white_check_mark: |
| < 4.0 | :x: |

## Reporting a Vulnerability

Use this section to tell people how to report a vulnerability.

Tell them where to go, how often they can expect to get an update on a
reported vulnerability, what to expect if the vulnerability is accepted or
declined, etc.
7 changes: 7 additions & 0 deletions tasks/soukai/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
transform: {
'^.+\\.(t|j)s$': 'ts-jest',
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(t|j)s$',
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
};
24 changes: 24 additions & 0 deletions tasks/soukai/lib/Workspaces.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Store } from 'vuex';
import Service from '@/services/Service';
import User from '@/models/users/User';
import Workspace from '@/models/soukai/Workspace';
interface State {
activeWorkspace: Workspace | null;
workspaces: Workspace[];
}
export default class Workspaces extends Service {
get empty(): boolean;
get active(): Workspace | null;
get all(): Workspace[];
setActive(workspace: Workspace | null): Promise<void>;
add(workspace: Workspace, activate?: boolean): void;
remove(workspace: Workspace): void;
protected get storage(): State;
protected init(): Promise<void>;
protected registerStoreModule(store: Store<State>): void;
protected unregisterStoreModule(store: Store<State>): void;
protected load(user: User): Promise<void>;
protected unload(): Promise<void>;
private loadWorkspace;
}
export {};
136 changes: 136 additions & 0 deletions tasks/soukai/lib/Workspaces.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Service_1 = __importDefault(require("@/services/Service"));
const Workspace_1 = __importDefault(require("@/models/soukai/Workspace"));
const EventBus_1 = __importDefault(require("@/utils/EventBus"));
const Storage_1 = __importDefault(require("@/utils/Storage"));
class Workspaces extends Service_1.default {
get empty() {
return !this.storage.workspaces || this.storage.workspaces.length === 0;
}
get active() {
return this.storage.activeWorkspace;
}
get all() {
return this.storage.workspaces;
}
setActive(workspace) {
return __awaiter(this, void 0, void 0, function* () {
this.app.$store.commit('setActiveWorkspace', workspace);
if (workspace)
Storage_1.default.set('activeWorkspaceId', workspace.id);
else
Storage_1.default.remove('activeWorkspaceId');
});
}
add(workspace, activate = true) {
this.app.$store.commit('addWorkspace', workspace);
if (activate)
this.setActive(workspace);
}
remove(workspace) {
this.app.$store.commit('removeWorkspace', workspace);
this.setActive(this.all.length > 0 ? this.all[0] : null);
}
get storage() {
return this.app.$store.state.workspaces
? this.app.$store.state.workspaces
: {};
}
init() {
const _super = Object.create(null, {
init: { get: () => super.init }
});
return __awaiter(this, void 0, void 0, function* () {
yield _super.init.call(this);
yield this.app.$auth.ready;
if (this.app.$auth.isLoggedIn()) {
yield this.load(this.app.$auth.user);
}
EventBus_1.default.on('login', this.load.bind(this));
EventBus_1.default.on('logout', this.unload.bind(this));
});
}
registerStoreModule(store) {
store.registerModule('workspaces', {
state: {
activeWorkspace: null,
workspaces: [],
},
mutations: {
setActiveWorkspace(state, activeWorkspace) {
state.activeWorkspace = activeWorkspace;
},
setWorkspaces(state, workspaces) {
state.workspaces = workspaces;
},
addWorkspace(state, workspace) {
state.workspaces.push(workspace);
},
removeWorkspace(state, workspace) {
const index = state.workspaces.findIndex(existingWorkspace => existingWorkspace === workspace);
if (index !== -1) {
state.workspaces.splice(index, 1);
}
},
},
});
}
unregisterStoreModule(store) {
store.unregisterModule('workspaces');
}
load(user) {
return __awaiter(this, void 0, void 0, function* () {
const workspaces = [];
const activeWorkspaceId = Storage_1.default.get('activeWorkspaceId');
const activeListId = Storage_1.default.get('activeListId');
let activeWorkspace;
for (const storage of user.storages) {
workspaces.push(...(yield Workspace_1.default.from(storage).all()));
}
activeWorkspace = workspaces.find(workspace => workspace.id === activeWorkspaceId);
if (!activeWorkspace && workspaces.length > 0)
activeWorkspace = workspaces[0];
if (activeWorkspace)
yield this.loadWorkspace(activeWorkspace, activeListId);
this.app.$store.commit('setWorkspaces', workspaces);
this.app.$store.commit('setActiveWorkspace', activeWorkspace);
});
}
unload() {
return __awaiter(this, void 0, void 0, function* () {
this.app.$store.commit('setWorkspaces', []);
this.app.$store.commit('setActiveWorkspace', null);
Storage_1.default.remove('activeWorkspaceId');
Storage_1.default.remove('activeListId');
});
}
loadWorkspace(workspace, activeListId) {
return __awaiter(this, void 0, void 0, function* () {
if (!workspace.isRelationLoaded('lists')) {
yield workspace.loadRelation('lists');
// TODO this could be done automatically in Soukai
for (const list of workspace.lists) {
list.setRelationModels('workspace', workspace);
}
}
workspace.setActiveList(workspace.lists.find(list => list.id === activeListId) ||
workspace.activeList);
if (workspace && !workspace.activeList.isRelationLoaded('tasks'))
yield workspace.activeList.loadRelation('tasks');
});
}
}
exports.default = Workspaces;
7 changes: 7 additions & 0 deletions tasks/soukai/lib/helpers/uuid.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// <reference types="node" />
import crypto from 'node:crypto';
export declare class Uuid {
v4(options?: crypto.RandomUUIDOptions | undefined): string;
}
declare const _default: Uuid;
export default _default;
14 changes: 14 additions & 0 deletions tasks/soukai/lib/helpers/uuid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Uuid = void 0;
const node_crypto_1 = __importDefault(require("node:crypto"));
class Uuid {
v4(options) {
return node_crypto_1.default.randomUUID(options);
}
}
exports.Uuid = Uuid;
exports.default = new Uuid();
3 changes: 3 additions & 0 deletions tasks/soukai/lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import User from './models/users/User';
import Workspace from './models/soukai/Workspace';
export declare function getWorkspaces(user: User): Promise<Workspace[]>;
26 changes: 26 additions & 0 deletions tasks/soukai/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWorkspaces = void 0;
const Workspace_1 = __importDefault(require("./models/soukai/Workspace"));
function getWorkspaces(user) {
return __awaiter(this, void 0, void 0, function* () {
const workspaces = [];
for (const storage of user.storages) {
workspaces.push(...(yield Workspace_1.default.from(storage).all()));
}
return workspaces;
});
}
exports.getWorkspaces = getWorkspaces;
Loading