@webiny/api-dashboard 0.0.0-stage → 0.0.0-unstable.7c2def32a7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DashboardAppFeature.d.ts +9 -0
- package/DashboardAppFeature.js +15 -0
- package/DashboardAppFeature.js.map +1 -0
- package/LICENSE +21 -0
- package/README.md +10 -2
- package/domain/dashboardKey.d.ts +1 -0
- package/domain/dashboardKey.js +4 -0
- package/domain/dashboardKey.js.map +1 -0
- package/domain/errors.d.ts +15 -0
- package/domain/errors.js +28 -0
- package/domain/errors.js.map +1 -0
- package/domain/types.d.ts +9 -0
- package/domain/types.js +0 -0
- package/features/ListDashboards/ListDashboardsRepository.d.ts +13 -0
- package/features/ListDashboards/ListDashboardsRepository.js +28 -0
- package/features/ListDashboards/ListDashboardsRepository.js.map +1 -0
- package/features/ListDashboards/ListDashboardsUseCase.d.ts +15 -0
- package/features/ListDashboards/ListDashboardsUseCase.js +30 -0
- package/features/ListDashboards/ListDashboardsUseCase.js.map +1 -0
- package/features/ListDashboards/abstractions.d.ts +34 -0
- package/features/ListDashboards/abstractions.js +6 -0
- package/features/ListDashboards/abstractions.js.map +1 -0
- package/features/ListDashboards/feature.d.ts +4 -0
- package/features/ListDashboards/feature.js +13 -0
- package/features/ListDashboards/feature.js.map +1 -0
- package/features/ListDashboards/index.d.ts +2 -0
- package/features/ListDashboards/index.js +2 -0
- package/features/UpdateDashboard/UpdateDashboardRepository.d.ts +13 -0
- package/features/UpdateDashboard/UpdateDashboardRepository.js +25 -0
- package/features/UpdateDashboard/UpdateDashboardRepository.js.map +1 -0
- package/features/UpdateDashboard/UpdateDashboardUseCase.d.ts +15 -0
- package/features/UpdateDashboard/UpdateDashboardUseCase.js +31 -0
- package/features/UpdateDashboard/UpdateDashboardUseCase.js.map +1 -0
- package/features/UpdateDashboard/abstractions.d.ts +35 -0
- package/features/UpdateDashboard/abstractions.js +6 -0
- package/features/UpdateDashboard/abstractions.js.map +1 -0
- package/features/UpdateDashboard/feature.d.ts +4 -0
- package/features/UpdateDashboard/feature.js +13 -0
- package/features/UpdateDashboard/feature.js.map +1 -0
- package/features/UpdateDashboard/index.d.ts +2 -0
- package/features/UpdateDashboard/index.js +2 -0
- package/features/UpdateDashboard/schema.d.ts +6 -0
- package/features/UpdateDashboard/schema.js +10 -0
- package/features/UpdateDashboard/schema.js.map +1 -0
- package/graphql/DashboardGraphQLSchema.d.ts +10 -0
- package/graphql/DashboardGraphQLSchema.js +105 -0
- package/graphql/DashboardGraphQLSchema.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/package.json +35 -5
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Container } from "@webiny/feature/api";
|
|
2
|
+
/**
|
|
3
|
+
* Stores each identity's admin dashboard layout in the key-value store, keyed by the identity ID,
|
|
4
|
+
* so users and identities don't need to know dashboards exist.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DashboardAppFeature: {
|
|
7
|
+
name: string;
|
|
8
|
+
register(container: Container): void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { ListDashboardsFeature } from "./features/ListDashboards/index.js";
|
|
3
|
+
import { UpdateDashboardFeature } from "./features/UpdateDashboard/index.js";
|
|
4
|
+
import { DashboardGraphQLSchema } from "./graphql/DashboardGraphQLSchema.js";
|
|
5
|
+
const DashboardAppFeature = createFeature({
|
|
6
|
+
name: "DashboardApp",
|
|
7
|
+
register (container) {
|
|
8
|
+
ListDashboardsFeature.register(container);
|
|
9
|
+
UpdateDashboardFeature.register(container);
|
|
10
|
+
container.register(DashboardGraphQLSchema);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export { DashboardAppFeature };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=DashboardAppFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DashboardAppFeature.js","sources":["../src/DashboardAppFeature.ts"],"sourcesContent":["import type { Container } from \"@webiny/feature/api\";\nimport { createFeature } from \"@webiny/feature/api\";\nimport { ListDashboardsFeature } from \"~/features/ListDashboards/index.js\";\nimport { UpdateDashboardFeature } from \"~/features/UpdateDashboard/index.js\";\nimport { DashboardGraphQLSchema } from \"~/graphql/DashboardGraphQLSchema.js\";\n\n/**\n * Stores each identity's admin dashboard layout in the key-value store, keyed by the identity ID,\n * so users and identities don't need to know dashboards exist.\n */\nexport const DashboardAppFeature = createFeature({\n name: \"DashboardApp\",\n register(container: Container) {\n ListDashboardsFeature.register(container);\n UpdateDashboardFeature.register(container);\n container.register(DashboardGraphQLSchema);\n }\n});\n"],"names":["DashboardAppFeature","createFeature","container","ListDashboardsFeature","UpdateDashboardFeature","DashboardGraphQLSchema"],"mappings":";;;;AAUO,MAAMA,sBAAsBC,cAAc;IAC7C,MAAM;IACN,UAASC,SAAoB;QACzBC,sBAAsB,QAAQ,CAACD;QAC/BE,uBAAuB,QAAQ,CAACF;QAChCA,UAAU,QAAQ,CAACG;IACvB;AACJ"}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @webiny/api-dashboard
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createDashboardKey: (ownerId: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain/dashboardKey.js","sources":["../../src/domain/dashboardKey.ts"],"sourcesContent":["// Each identity has one layout per tenant. The key-value store already scopes keys by tenant.\nexport const createDashboardKey = (ownerId: string): string => {\n return `adminDashboard:${ownerId}`;\n};\n"],"names":["createDashboardKey","ownerId"],"mappings":"AACO,MAAMA,qBAAqB,CAACC,UACxB,CAAC,eAAe,EAAEA,SAAS"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseError } from "@webiny/feature/api";
|
|
2
|
+
export declare class DashboardNotAuthenticatedError extends BaseError {
|
|
3
|
+
readonly code: "Dashboard/NotAuthenticated";
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
|
6
|
+
export declare class DashboardPersistenceError extends BaseError {
|
|
7
|
+
readonly code: "Dashboard/PersistenceError";
|
|
8
|
+
constructor(error: Error);
|
|
9
|
+
}
|
|
10
|
+
export declare class DashboardValidationError extends BaseError<{
|
|
11
|
+
message: string;
|
|
12
|
+
}> {
|
|
13
|
+
readonly code: "Dashboard/Validation";
|
|
14
|
+
constructor(message: string);
|
|
15
|
+
}
|
package/domain/errors.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseError } from "@webiny/feature/api";
|
|
2
|
+
class DashboardNotAuthenticatedError extends BaseError {
|
|
3
|
+
constructor(){
|
|
4
|
+
super({
|
|
5
|
+
message: "Only a signed-in identity has a dashboard."
|
|
6
|
+
}), this.code = "Dashboard/NotAuthenticated";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
class DashboardPersistenceError extends BaseError {
|
|
10
|
+
constructor(error){
|
|
11
|
+
super({
|
|
12
|
+
message: error.message
|
|
13
|
+
}), this.code = "Dashboard/PersistenceError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class DashboardValidationError extends BaseError {
|
|
17
|
+
constructor(message){
|
|
18
|
+
super({
|
|
19
|
+
message,
|
|
20
|
+
data: {
|
|
21
|
+
message
|
|
22
|
+
}
|
|
23
|
+
}), this.code = "Dashboard/Validation";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export { DashboardNotAuthenticatedError, DashboardPersistenceError, DashboardValidationError };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain/errors.js","sources":["../../src/domain/errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\n\nexport class DashboardNotAuthenticatedError extends BaseError {\n override readonly code = \"Dashboard/NotAuthenticated\" as const;\n\n constructor() {\n super({\n message: \"Only a signed-in identity has a dashboard.\"\n });\n }\n}\n\nexport class DashboardPersistenceError extends BaseError {\n override readonly code = \"Dashboard/PersistenceError\" as const;\n\n constructor(error: Error) {\n super({\n message: error.message\n });\n }\n}\n\nexport class DashboardValidationError extends BaseError<{ message: string }> {\n override readonly code = \"Dashboard/Validation\" as const;\n\n constructor(message: string) {\n super({\n message,\n data: { message }\n });\n }\n}\n"],"names":["DashboardNotAuthenticatedError","BaseError","DashboardPersistenceError","error","DashboardValidationError","message"],"mappings":";AAEO,MAAMA,uCAAuCC;IAGhD,aAAc;QACV,KAAK,CAAC;YACF,SAAS;QACb,SALc,IAAI,GAAG;IAMzB;AACJ;AAEO,MAAMC,kCAAkCD;IAG3C,YAAYE,KAAY,CAAE;QACtB,KAAK,CAAC;YACF,SAASA,MAAM,OAAO;QAC1B,SALc,IAAI,GAAG;IAMzB;AACJ;AAEO,MAAMC,iCAAiCH;IAG1C,YAAYI,OAAe,CAAE;QACzB,KAAK,CAAC;YACFA;YACA,MAAM;gBAAEA;YAAQ;QACpB,SANc,IAAI,GAAG;IAOzB;AACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A user's admin dashboard layout: an ordered list of widget names per column (`columns[i]` is
|
|
3
|
+
* column i), the widgets the user removed (`hidden`), and how many columns the user chose.
|
|
4
|
+
*/
|
|
5
|
+
export interface DashboardLayout {
|
|
6
|
+
columns: string[][];
|
|
7
|
+
hidden: string[];
|
|
8
|
+
columnCount: number;
|
|
9
|
+
}
|
package/domain/types.js
ADDED
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
3
|
+
import { ListDashboardsRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
4
|
+
import type { DashboardLayout } from "../../domain/types.js";
|
|
5
|
+
declare class ListDashboardsRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
6
|
+
private keyValueStore;
|
|
7
|
+
constructor(keyValueStore: KeyValueStore.Interface);
|
|
8
|
+
get(ownerId: string): Promise<Result<DashboardLayout | null, RepositoryAbstraction.Error>>;
|
|
9
|
+
}
|
|
10
|
+
export declare const ListDashboardsRepository: typeof ListDashboardsRepositoryImpl & {
|
|
11
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IListDashboardsRepository>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
3
|
+
import { ListDashboardsRepository } from "./abstractions.js";
|
|
4
|
+
import { DashboardPersistenceError } from "../../domain/errors.js";
|
|
5
|
+
import { createDashboardKey } from "../../domain/dashboardKey.js";
|
|
6
|
+
class ListDashboardsRepositoryImpl {
|
|
7
|
+
constructor(keyValueStore){
|
|
8
|
+
this.keyValueStore = keyValueStore;
|
|
9
|
+
}
|
|
10
|
+
async get(ownerId) {
|
|
11
|
+
const key = createDashboardKey(ownerId);
|
|
12
|
+
const result = await this.keyValueStore.get(key);
|
|
13
|
+
if (result.isFail()) {
|
|
14
|
+
if ("KeyValueStore/KeyNotFound" === result.error.code) return Result.ok(null);
|
|
15
|
+
return Result.fail(new DashboardPersistenceError(result.error));
|
|
16
|
+
}
|
|
17
|
+
return Result.ok(result.value);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const ListDashboardsRepository_ListDashboardsRepository = ListDashboardsRepository.createImplementation({
|
|
21
|
+
implementation: ListDashboardsRepositoryImpl,
|
|
22
|
+
dependencies: [
|
|
23
|
+
KeyValueStore
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
export { ListDashboardsRepository_ListDashboardsRepository as ListDashboardsRepository };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=ListDashboardsRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ListDashboards/ListDashboardsRepository.js","sources":["../../../src/features/ListDashboards/ListDashboardsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { ListDashboardsRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { DashboardPersistenceError } from \"~/domain/errors.js\";\nimport { createDashboardKey } from \"~/domain/dashboardKey.js\";\nimport type { DashboardLayout } from \"~/domain/types.js\";\n\nclass ListDashboardsRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(private keyValueStore: KeyValueStore.Interface) {}\n\n async get(\n ownerId: string\n ): Promise<Result<DashboardLayout | null, RepositoryAbstraction.Error>> {\n const key = createDashboardKey(ownerId);\n const result = await this.keyValueStore.get<DashboardLayout>(key);\n if (result.isFail()) {\n if (result.error.code === \"KeyValueStore/KeyNotFound\") {\n return Result.ok(null);\n }\n return Result.fail(new DashboardPersistenceError(result.error));\n }\n\n return Result.ok(result.value);\n }\n}\n\nexport const ListDashboardsRepository = RepositoryAbstraction.createImplementation({\n implementation: ListDashboardsRepositoryImpl,\n dependencies: [KeyValueStore]\n});\n"],"names":["ListDashboardsRepositoryImpl","keyValueStore","ownerId","key","createDashboardKey","result","Result","DashboardPersistenceError","ListDashboardsRepository","RepositoryAbstraction","KeyValueStore"],"mappings":";;;;;AAOA,MAAMA;IACF,YAAoBC,aAAsC,CAAE;aAAxCA,aAAa,GAAbA;IAAyC;IAE7D,MAAM,IACFC,OAAe,EACqD;QACpE,MAAMC,MAAMC,mBAAmBF;QAC/B,MAAMG,SAAS,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAkBF;QAC7D,IAAIE,OAAO,MAAM,IAAI;YACjB,IAAIA,AAAsB,gCAAtBA,OAAO,KAAK,CAAC,IAAI,EACjB,OAAOC,OAAO,EAAE,CAAC;YAErB,OAAOA,OAAO,IAAI,CAAC,IAAIC,0BAA0BF,OAAO,KAAK;QACjE;QAEA,OAAOC,OAAO,EAAE,CAACD,OAAO,KAAK;IACjC;AACJ;AAEO,MAAMG,oDAA2BC,yBAAAA,oBAA0C,CAAC;IAC/E,gBAAgBT;IAChB,cAAc;QAACU;KAAc;AACjC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
+
import { ListDashboardsUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
4
|
+
import { ListDashboardsRepository } from "./abstractions.js";
|
|
5
|
+
import type { DashboardLayout } from "../../domain/types.js";
|
|
6
|
+
declare class ListDashboardsUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
7
|
+
private identityContext;
|
|
8
|
+
private repository;
|
|
9
|
+
constructor(identityContext: IdentityContext.Interface, repository: ListDashboardsRepository.Interface);
|
|
10
|
+
execute(): Promise<Result<DashboardLayout[], UseCaseAbstraction.Error>>;
|
|
11
|
+
}
|
|
12
|
+
export declare const ListDashboardsUseCase: typeof ListDashboardsUseCaseImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IListDashboardsUseCase>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
+
import { ListDashboardsRepository, ListDashboardsUseCase } from "./abstractions.js";
|
|
4
|
+
import { DashboardNotAuthenticatedError } from "../../domain/errors.js";
|
|
5
|
+
class ListDashboardsUseCaseImpl {
|
|
6
|
+
constructor(identityContext, repository){
|
|
7
|
+
this.identityContext = identityContext;
|
|
8
|
+
this.repository = repository;
|
|
9
|
+
}
|
|
10
|
+
async execute() {
|
|
11
|
+
const identity = this.identityContext.getIdentity();
|
|
12
|
+
if (!identity || identity.isAnonymous()) return Result.fail(new DashboardNotAuthenticatedError());
|
|
13
|
+
const result = await this.repository.get(identity.id);
|
|
14
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
15
|
+
if (!result.value) return Result.ok([]);
|
|
16
|
+
return Result.ok([
|
|
17
|
+
result.value
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const ListDashboardsUseCase_ListDashboardsUseCase = ListDashboardsUseCase.createImplementation({
|
|
22
|
+
implementation: ListDashboardsUseCaseImpl,
|
|
23
|
+
dependencies: [
|
|
24
|
+
IdentityContext,
|
|
25
|
+
ListDashboardsRepository
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
export { ListDashboardsUseCase_ListDashboardsUseCase as ListDashboardsUseCase };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=ListDashboardsUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ListDashboards/ListDashboardsUseCase.js","sources":["../../../src/features/ListDashboards/ListDashboardsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { ListDashboardsUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { ListDashboardsRepository } from \"./abstractions.js\";\nimport { DashboardNotAuthenticatedError } from \"~/domain/errors.js\";\nimport type { DashboardLayout } from \"~/domain/types.js\";\n\nclass ListDashboardsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private repository: ListDashboardsRepository.Interface\n ) {}\n\n async execute(): Promise<Result<DashboardLayout[], UseCaseAbstraction.Error>> {\n const identity = this.identityContext.getIdentity();\n if (!identity || identity.isAnonymous()) {\n return Result.fail(new DashboardNotAuthenticatedError());\n }\n\n const result = await this.repository.get(identity.id);\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n if (!result.value) {\n return Result.ok([]);\n }\n return Result.ok([result.value]);\n }\n}\n\nexport const ListDashboardsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListDashboardsUseCaseImpl,\n dependencies: [IdentityContext, ListDashboardsRepository]\n});\n"],"names":["ListDashboardsUseCaseImpl","identityContext","repository","identity","Result","DashboardNotAuthenticatedError","result","ListDashboardsUseCase","UseCaseAbstraction","IdentityContext","ListDashboardsRepository"],"mappings":";;;;AAOA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,UAA8C,CACxD;aAFUD,eAAe,GAAfA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,UAAwE;QAC1E,MAAMC,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,IAAI,CAACA,YAAYA,SAAS,WAAW,IACjC,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAACH,SAAS,EAAE;QACpD,IAAIG,OAAO,MAAM,IACb,OAAOF,OAAO,IAAI,CAACE,OAAO,KAAK;QAEnC,IAAI,CAACA,OAAO,KAAK,EACb,OAAOF,OAAO,EAAE,CAAC,EAAE;QAEvB,OAAOA,OAAO,EAAE,CAAC;YAACE,OAAO,KAAK;SAAC;IACnC;AACJ;AAEO,MAAMC,8CAAwBC,sBAAAA,oBAAuC,CAAC;IACzE,gBAAgBR;IAChB,cAAc;QAACS;QAAiBC;KAAyB;AAC7D"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { DashboardLayout } from "../../domain/types.js";
|
|
3
|
+
import type { DashboardNotAuthenticatedError } from "../../domain/errors.js";
|
|
4
|
+
import type { DashboardPersistenceError } from "../../domain/errors.js";
|
|
5
|
+
/**
|
|
6
|
+
* ListDashboards Use Case - Returns the current identity's dashboards. Each identity has at most
|
|
7
|
+
* one today, and none until it customizes the dashboard.
|
|
8
|
+
*/
|
|
9
|
+
export interface IListDashboardsUseCase {
|
|
10
|
+
execute(): Promise<Result<DashboardLayout[], UseCaseError>>;
|
|
11
|
+
}
|
|
12
|
+
export interface IListDashboardsUseCaseErrors {
|
|
13
|
+
notAuthenticated: DashboardNotAuthenticatedError;
|
|
14
|
+
persistence: DashboardPersistenceError;
|
|
15
|
+
}
|
|
16
|
+
type UseCaseError = IListDashboardsUseCaseErrors[keyof IListDashboardsUseCaseErrors];
|
|
17
|
+
export declare const ListDashboardsUseCase: import("@webiny/di").Abstraction<IListDashboardsUseCase>;
|
|
18
|
+
export declare namespace ListDashboardsUseCase {
|
|
19
|
+
type Interface = IListDashboardsUseCase;
|
|
20
|
+
type Error = UseCaseError;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* ListDashboardsRepository - Loads an owner's dashboard layout from storage, or `null` if none is stored.
|
|
24
|
+
*/
|
|
25
|
+
export interface IListDashboardsRepository {
|
|
26
|
+
get(ownerId: string): Promise<Result<DashboardLayout | null, RepositoryError>>;
|
|
27
|
+
}
|
|
28
|
+
type RepositoryError = DashboardPersistenceError;
|
|
29
|
+
export declare const ListDashboardsRepository: import("@webiny/di").Abstraction<IListDashboardsRepository>;
|
|
30
|
+
export declare namespace ListDashboardsRepository {
|
|
31
|
+
type Interface = IListDashboardsRepository;
|
|
32
|
+
type Error = RepositoryError;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
const ListDashboardsUseCase = createAbstraction("ListDashboardsUseCase");
|
|
3
|
+
const ListDashboardsRepository = createAbstraction("ListDashboardsRepository");
|
|
4
|
+
export { ListDashboardsRepository, ListDashboardsUseCase };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ListDashboards/abstractions.js","sources":["../../../src/features/ListDashboards/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { DashboardLayout } from \"~/domain/types.js\";\nimport type { DashboardNotAuthenticatedError } from \"~/domain/errors.js\";\nimport type { DashboardPersistenceError } from \"~/domain/errors.js\";\n\n/**\n * ListDashboards Use Case - Returns the current identity's dashboards. Each identity has at most\n * one today, and none until it customizes the dashboard.\n */\nexport interface IListDashboardsUseCase {\n execute(): Promise<Result<DashboardLayout[], UseCaseError>>;\n}\n\nexport interface IListDashboardsUseCaseErrors {\n notAuthenticated: DashboardNotAuthenticatedError;\n persistence: DashboardPersistenceError;\n}\n\ntype UseCaseError = IListDashboardsUseCaseErrors[keyof IListDashboardsUseCaseErrors];\n\nexport const ListDashboardsUseCase =\n createAbstraction<IListDashboardsUseCase>(\"ListDashboardsUseCase\");\n\nexport namespace ListDashboardsUseCase {\n export type Interface = IListDashboardsUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * ListDashboardsRepository - Loads an owner's dashboard layout from storage, or `null` if none is stored.\n */\nexport interface IListDashboardsRepository {\n get(ownerId: string): Promise<Result<DashboardLayout | null, RepositoryError>>;\n}\n\ntype RepositoryError = DashboardPersistenceError;\n\nexport const ListDashboardsRepository = createAbstraction<IListDashboardsRepository>(\n \"ListDashboardsRepository\"\n);\n\nexport namespace ListDashboardsRepository {\n export type Interface = IListDashboardsRepository;\n export type Error = RepositoryError;\n}\n"],"names":["ListDashboardsUseCase","createAbstraction","ListDashboardsRepository"],"mappings":";AAqBO,MAAMA,wBACTC,kBAA0C;AAgBvC,MAAMC,2BAA2BD,kBACpC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { ListDashboardsUseCase } from "./ListDashboardsUseCase.js";
|
|
3
|
+
import { ListDashboardsRepository } from "./ListDashboardsRepository.js";
|
|
4
|
+
const ListDashboardsFeature = createFeature({
|
|
5
|
+
name: "ListDashboards",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(ListDashboardsUseCase);
|
|
8
|
+
container.register(ListDashboardsRepository).inSingletonScope();
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export { ListDashboardsFeature };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ListDashboards/feature.js","sources":["../../../src/features/ListDashboards/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListDashboardsUseCase } from \"./ListDashboardsUseCase.js\";\nimport { ListDashboardsRepository } from \"./ListDashboardsRepository.js\";\n\nexport const ListDashboardsFeature = createFeature({\n name: \"ListDashboards\",\n register(container) {\n container.register(ListDashboardsUseCase);\n container.register(ListDashboardsRepository).inSingletonScope();\n }\n});\n"],"names":["ListDashboardsFeature","createFeature","container","ListDashboardsUseCase","ListDashboardsRepository"],"mappings":";;;AAIO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,0BAA0B,gBAAgB;IACjE;AACJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
3
|
+
import { UpdateDashboardRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
4
|
+
import type { DashboardLayout } from "../../domain/types.js";
|
|
5
|
+
declare class UpdateDashboardRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
6
|
+
private keyValueStore;
|
|
7
|
+
constructor(keyValueStore: KeyValueStore.Interface);
|
|
8
|
+
save(ownerId: string, layout: DashboardLayout): Promise<Result<DashboardLayout, RepositoryAbstraction.Error>>;
|
|
9
|
+
}
|
|
10
|
+
export declare const UpdateDashboardRepository: typeof UpdateDashboardRepositoryImpl & {
|
|
11
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUpdateDashboardRepository>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
3
|
+
import { UpdateDashboardRepository } from "./abstractions.js";
|
|
4
|
+
import { DashboardPersistenceError } from "../../domain/errors.js";
|
|
5
|
+
import { createDashboardKey } from "../../domain/dashboardKey.js";
|
|
6
|
+
class UpdateDashboardRepositoryImpl {
|
|
7
|
+
constructor(keyValueStore){
|
|
8
|
+
this.keyValueStore = keyValueStore;
|
|
9
|
+
}
|
|
10
|
+
async save(ownerId, layout) {
|
|
11
|
+
const key = createDashboardKey(ownerId);
|
|
12
|
+
const result = await this.keyValueStore.set(key, layout);
|
|
13
|
+
if (result.isFail()) return Result.fail(new DashboardPersistenceError(result.error));
|
|
14
|
+
return Result.ok(layout);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const UpdateDashboardRepository_UpdateDashboardRepository = UpdateDashboardRepository.createImplementation({
|
|
18
|
+
implementation: UpdateDashboardRepositoryImpl,
|
|
19
|
+
dependencies: [
|
|
20
|
+
KeyValueStore
|
|
21
|
+
]
|
|
22
|
+
});
|
|
23
|
+
export { UpdateDashboardRepository_UpdateDashboardRepository as UpdateDashboardRepository };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=UpdateDashboardRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UpdateDashboard/UpdateDashboardRepository.js","sources":["../../../src/features/UpdateDashboard/UpdateDashboardRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { UpdateDashboardRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { DashboardPersistenceError } from \"~/domain/errors.js\";\nimport { createDashboardKey } from \"~/domain/dashboardKey.js\";\nimport type { DashboardLayout } from \"~/domain/types.js\";\n\nclass UpdateDashboardRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(private keyValueStore: KeyValueStore.Interface) {}\n\n async save(\n ownerId: string,\n layout: DashboardLayout\n ): Promise<Result<DashboardLayout, RepositoryAbstraction.Error>> {\n const key = createDashboardKey(ownerId);\n const result = await this.keyValueStore.set(key, layout);\n if (result.isFail()) {\n return Result.fail(new DashboardPersistenceError(result.error));\n }\n\n return Result.ok(layout);\n }\n}\n\nexport const UpdateDashboardRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateDashboardRepositoryImpl,\n dependencies: [KeyValueStore]\n});\n"],"names":["UpdateDashboardRepositoryImpl","keyValueStore","ownerId","layout","key","createDashboardKey","result","Result","DashboardPersistenceError","UpdateDashboardRepository","RepositoryAbstraction","KeyValueStore"],"mappings":";;;;;AAOA,MAAMA;IACF,YAAoBC,aAAsC,CAAE;aAAxCA,aAAa,GAAbA;IAAyC;IAE7D,MAAM,KACFC,OAAe,EACfC,MAAuB,EACsC;QAC7D,MAAMC,MAAMC,mBAAmBH;QAC/B,MAAMI,SAAS,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAACF,KAAKD;QACjD,IAAIG,OAAO,MAAM,IACb,OAAOC,OAAO,IAAI,CAAC,IAAIC,0BAA0BF,OAAO,KAAK;QAGjE,OAAOC,OAAO,EAAE,CAACJ;IACrB;AACJ;AAEO,MAAMM,sDAA4BC,0BAAAA,oBAA0C,CAAC;IAChF,gBAAgBV;IAChB,cAAc;QAACW;KAAc;AACjC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
+
import { UpdateDashboardUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
4
|
+
import { UpdateDashboardRepository } from "./abstractions.js";
|
|
5
|
+
import type { DashboardLayout } from "../../domain/types.js";
|
|
6
|
+
declare class UpdateDashboardUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
7
|
+
private identityContext;
|
|
8
|
+
private repository;
|
|
9
|
+
constructor(identityContext: IdentityContext.Interface, repository: UpdateDashboardRepository.Interface);
|
|
10
|
+
execute(layout: DashboardLayout): Promise<Result<DashboardLayout, UseCaseAbstraction.Error>>;
|
|
11
|
+
}
|
|
12
|
+
export declare const UpdateDashboardUseCase: typeof UpdateDashboardUseCaseImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUpdateDashboardUseCase>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
+
import { UpdateDashboardRepository, UpdateDashboardUseCase } from "./abstractions.js";
|
|
4
|
+
import { DashboardNotAuthenticatedError, DashboardValidationError } from "../../domain/errors.js";
|
|
5
|
+
import { updateDashboardValidation } from "./schema.js";
|
|
6
|
+
class UpdateDashboardUseCaseImpl {
|
|
7
|
+
constructor(identityContext, repository){
|
|
8
|
+
this.identityContext = identityContext;
|
|
9
|
+
this.repository = repository;
|
|
10
|
+
}
|
|
11
|
+
async execute(layout) {
|
|
12
|
+
const identity = this.identityContext.getIdentity();
|
|
13
|
+
if (!identity || identity.isAnonymous()) return Result.fail(new DashboardNotAuthenticatedError());
|
|
14
|
+
const validation = updateDashboardValidation.safeParse(layout);
|
|
15
|
+
if (!validation.success) {
|
|
16
|
+
const [issue] = validation.error.issues;
|
|
17
|
+
return Result.fail(new DashboardValidationError(issue.message));
|
|
18
|
+
}
|
|
19
|
+
return await this.repository.save(identity.id, validation.data);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const UpdateDashboardUseCase_UpdateDashboardUseCase = UpdateDashboardUseCase.createImplementation({
|
|
23
|
+
implementation: UpdateDashboardUseCaseImpl,
|
|
24
|
+
dependencies: [
|
|
25
|
+
IdentityContext,
|
|
26
|
+
UpdateDashboardRepository
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
export { UpdateDashboardUseCase_UpdateDashboardUseCase as UpdateDashboardUseCase };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=UpdateDashboardUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UpdateDashboard/UpdateDashboardUseCase.js","sources":["../../../src/features/UpdateDashboard/UpdateDashboardUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { UpdateDashboardUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { UpdateDashboardRepository } from \"./abstractions.js\";\nimport { DashboardNotAuthenticatedError } from \"~/domain/errors.js\";\nimport { DashboardValidationError } from \"~/domain/errors.js\";\nimport { updateDashboardValidation } from \"./schema.js\";\nimport type { DashboardLayout } from \"~/domain/types.js\";\n\nclass UpdateDashboardUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private repository: UpdateDashboardRepository.Interface\n ) {}\n\n async execute(\n layout: DashboardLayout\n ): Promise<Result<DashboardLayout, UseCaseAbstraction.Error>> {\n const identity = this.identityContext.getIdentity();\n if (!identity || identity.isAnonymous()) {\n return Result.fail(new DashboardNotAuthenticatedError());\n }\n\n const validation = updateDashboardValidation.safeParse(layout);\n if (!validation.success) {\n const [issue] = validation.error.issues;\n return Result.fail(new DashboardValidationError(issue.message));\n }\n\n return await this.repository.save(identity.id, validation.data);\n }\n}\n\nexport const UpdateDashboardUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateDashboardUseCaseImpl,\n dependencies: [IdentityContext, UpdateDashboardRepository]\n});\n"],"names":["UpdateDashboardUseCaseImpl","identityContext","repository","layout","identity","Result","DashboardNotAuthenticatedError","validation","updateDashboardValidation","issue","DashboardValidationError","UpdateDashboardUseCase","UseCaseAbstraction","IdentityContext","UpdateDashboardRepository"],"mappings":";;;;;AASA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,UAA+C,CACzD;aAFUD,eAAe,GAAfA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QACFC,MAAuB,EACmC;QAC1D,MAAMC,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,IAAI,CAACA,YAAYA,SAAS,WAAW,IACjC,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,aAAaC,0BAA0B,SAAS,CAACL;QACvD,IAAI,CAACI,WAAW,OAAO,EAAE;YACrB,MAAM,CAACE,MAAM,GAAGF,WAAW,KAAK,CAAC,MAAM;YACvC,OAAOF,OAAO,IAAI,CAAC,IAAIK,yBAAyBD,MAAM,OAAO;QACjE;QAEA,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAACL,SAAS,EAAE,EAAEG,WAAW,IAAI;IAClE;AACJ;AAEO,MAAMI,gDAAyBC,uBAAAA,oBAAuC,CAAC;IAC1E,gBAAgBZ;IAChB,cAAc;QAACa;QAAiBC;KAA0B;AAC9D"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { DashboardLayout } from "../../domain/types.js";
|
|
3
|
+
import type { DashboardNotAuthenticatedError } from "../../domain/errors.js";
|
|
4
|
+
import type { DashboardPersistenceError } from "../../domain/errors.js";
|
|
5
|
+
import type { DashboardValidationError } from "../../domain/errors.js";
|
|
6
|
+
/**
|
|
7
|
+
* UpdateDashboard Use Case - Stores the current identity's dashboard, creating it on first use.
|
|
8
|
+
*/
|
|
9
|
+
export interface IUpdateDashboardUseCase {
|
|
10
|
+
execute(layout: DashboardLayout): Promise<Result<DashboardLayout, UseCaseError>>;
|
|
11
|
+
}
|
|
12
|
+
export interface IUpdateDashboardUseCaseErrors {
|
|
13
|
+
notAuthenticated: DashboardNotAuthenticatedError;
|
|
14
|
+
validation: DashboardValidationError;
|
|
15
|
+
persistence: DashboardPersistenceError;
|
|
16
|
+
}
|
|
17
|
+
type UseCaseError = IUpdateDashboardUseCaseErrors[keyof IUpdateDashboardUseCaseErrors];
|
|
18
|
+
export declare const UpdateDashboardUseCase: import("@webiny/di").Abstraction<IUpdateDashboardUseCase>;
|
|
19
|
+
export declare namespace UpdateDashboardUseCase {
|
|
20
|
+
type Interface = IUpdateDashboardUseCase;
|
|
21
|
+
type Error = UseCaseError;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* UpdateDashboardRepository - Writes an owner's dashboard layout to storage.
|
|
25
|
+
*/
|
|
26
|
+
export interface IUpdateDashboardRepository {
|
|
27
|
+
save(ownerId: string, layout: DashboardLayout): Promise<Result<DashboardLayout, RepositoryError>>;
|
|
28
|
+
}
|
|
29
|
+
type RepositoryError = DashboardPersistenceError;
|
|
30
|
+
export declare const UpdateDashboardRepository: import("@webiny/di").Abstraction<IUpdateDashboardRepository>;
|
|
31
|
+
export declare namespace UpdateDashboardRepository {
|
|
32
|
+
type Interface = IUpdateDashboardRepository;
|
|
33
|
+
type Error = RepositoryError;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
const UpdateDashboardUseCase = createAbstraction("UpdateDashboardUseCase");
|
|
3
|
+
const UpdateDashboardRepository = createAbstraction("UpdateDashboardRepository");
|
|
4
|
+
export { UpdateDashboardRepository, UpdateDashboardUseCase };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UpdateDashboard/abstractions.js","sources":["../../../src/features/UpdateDashboard/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { DashboardLayout } from \"~/domain/types.js\";\nimport type { DashboardNotAuthenticatedError } from \"~/domain/errors.js\";\nimport type { DashboardPersistenceError } from \"~/domain/errors.js\";\nimport type { DashboardValidationError } from \"~/domain/errors.js\";\n\n/**\n * UpdateDashboard Use Case - Stores the current identity's dashboard, creating it on first use.\n */\nexport interface IUpdateDashboardUseCase {\n execute(layout: DashboardLayout): Promise<Result<DashboardLayout, UseCaseError>>;\n}\n\nexport interface IUpdateDashboardUseCaseErrors {\n notAuthenticated: DashboardNotAuthenticatedError;\n validation: DashboardValidationError;\n persistence: DashboardPersistenceError;\n}\n\ntype UseCaseError = IUpdateDashboardUseCaseErrors[keyof IUpdateDashboardUseCaseErrors];\n\nexport const UpdateDashboardUseCase =\n createAbstraction<IUpdateDashboardUseCase>(\"UpdateDashboardUseCase\");\n\nexport namespace UpdateDashboardUseCase {\n export type Interface = IUpdateDashboardUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * UpdateDashboardRepository - Writes an owner's dashboard layout to storage.\n */\nexport interface IUpdateDashboardRepository {\n save(\n ownerId: string,\n layout: DashboardLayout\n ): Promise<Result<DashboardLayout, RepositoryError>>;\n}\n\ntype RepositoryError = DashboardPersistenceError;\n\nexport const UpdateDashboardRepository = createAbstraction<IUpdateDashboardRepository>(\n \"UpdateDashboardRepository\"\n);\n\nexport namespace UpdateDashboardRepository {\n export type Interface = IUpdateDashboardRepository;\n export type Error = RepositoryError;\n}\n"],"names":["UpdateDashboardUseCase","createAbstraction","UpdateDashboardRepository"],"mappings":";AAsBO,MAAMA,yBACTC,kBAA2C;AAmBxC,MAAMC,4BAA4BD,kBACrC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { UpdateDashboardUseCase } from "./UpdateDashboardUseCase.js";
|
|
3
|
+
import { UpdateDashboardRepository } from "./UpdateDashboardRepository.js";
|
|
4
|
+
const UpdateDashboardFeature = createFeature({
|
|
5
|
+
name: "UpdateDashboard",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(UpdateDashboardUseCase);
|
|
8
|
+
container.register(UpdateDashboardRepository).inSingletonScope();
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export { UpdateDashboardFeature };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UpdateDashboard/feature.js","sources":["../../../src/features/UpdateDashboard/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { UpdateDashboardUseCase } from \"./UpdateDashboardUseCase.js\";\nimport { UpdateDashboardRepository } from \"./UpdateDashboardRepository.js\";\n\nexport const UpdateDashboardFeature = createFeature({\n name: \"UpdateDashboard\",\n register(container) {\n container.register(UpdateDashboardUseCase);\n container.register(UpdateDashboardRepository).inSingletonScope();\n }\n});\n"],"names":["UpdateDashboardFeature","createFeature","container","UpdateDashboardUseCase","UpdateDashboardRepository"],"mappings":";;;AAIO,MAAMA,yBAAyBC,cAAc;IAChD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,2BAA2B,gBAAgB;IAClE;AACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import zod from "zod";
|
|
2
|
+
const widgetName = zod.string().min(1).max(200);
|
|
3
|
+
const updateDashboardValidation = zod.object({
|
|
4
|
+
columns: zod.array(zod.array(widgetName).max(100)).max(4),
|
|
5
|
+
hidden: zod.array(widgetName).max(200),
|
|
6
|
+
columnCount: zod.number().int().min(2).max(4)
|
|
7
|
+
});
|
|
8
|
+
export { updateDashboardValidation };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UpdateDashboard/schema.js","sources":["../../../src/features/UpdateDashboard/schema.ts"],"sourcesContent":["import zod from \"zod\";\n\nconst widgetName = zod.string().min(1).max(200);\n\n// Bounds match the admin dashboard (2 to 4 columns), and keep the stored entry small.\nexport const updateDashboardValidation = zod.object({\n columns: zod.array(zod.array(widgetName).max(100)).max(4),\n hidden: zod.array(widgetName).max(200),\n columnCount: zod.number().int().min(2).max(4)\n});\n"],"names":["widgetName","zod","updateDashboardValidation"],"mappings":";AAEA,MAAMA,aAAaC,IAAI,MAAM,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAGpC,MAAMC,4BAA4BD,IAAI,MAAM,CAAC;IAChD,SAASA,IAAI,KAAK,CAACA,IAAI,KAAK,CAACD,YAAY,GAAG,CAAC,MAAM,GAAG,CAAC;IACvD,QAAQC,IAAI,KAAK,CAACD,YAAY,GAAG,CAAC;IAClC,aAAaC,IAAI,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAC/C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { GraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
|
|
3
|
+
declare class DashboardGraphQLSchemaImpl implements CoreGraphQLSchemaFactory.Interface {
|
|
4
|
+
getSchemaKey: () => string;
|
|
5
|
+
execute(builder: GraphQLSchemaBuilder.Interface): CoreGraphQLSchemaFactory.Return;
|
|
6
|
+
}
|
|
7
|
+
export declare const DashboardGraphQLSchema: typeof DashboardGraphQLSchemaImpl & {
|
|
8
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-graphql/graphql/abstractions.core").ICoreGraphQLSchemaFactory>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { resolve } from "@webiny/api-graphql";
|
|
2
|
+
import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
|
|
3
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
4
|
+
import { ListDashboardsUseCase } from "../features/ListDashboards/abstractions.js";
|
|
5
|
+
import { UpdateDashboardUseCase } from "../features/UpdateDashboard/abstractions.js";
|
|
6
|
+
const TYPE_DEFS = `
|
|
7
|
+
type Dashboard {
|
|
8
|
+
columns: [[String!]!]!
|
|
9
|
+
hidden: [String!]!
|
|
10
|
+
columnCount: Int!
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
input DashboardInput {
|
|
14
|
+
columns: [[String!]!]!
|
|
15
|
+
hidden: [String!]!
|
|
16
|
+
columnCount: Int!
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type DashboardError {
|
|
20
|
+
code: String
|
|
21
|
+
message: String!
|
|
22
|
+
data: JSON
|
|
23
|
+
stack: String
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type DashboardResponse {
|
|
27
|
+
data: Dashboard
|
|
28
|
+
error: DashboardError
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type DashboardListResponse {
|
|
32
|
+
data: [Dashboard!]
|
|
33
|
+
error: DashboardError
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type DashboardQuery {
|
|
37
|
+
# The current identity's dashboards: empty until it customizes one, at most one for now.
|
|
38
|
+
listDashboards: DashboardListResponse!
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type DashboardMutation {
|
|
42
|
+
# Creates the identity's dashboard on first use.
|
|
43
|
+
updateDashboard(data: DashboardInput!): DashboardResponse!
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
extend type Query {
|
|
47
|
+
dashboard: DashboardQuery
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
extend type Mutation {
|
|
51
|
+
dashboard: DashboardMutation
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
class DashboardGraphQLSchemaImpl {
|
|
55
|
+
async execute(builder) {
|
|
56
|
+
builder.addTypeDefs(TYPE_DEFS);
|
|
57
|
+
builder.addResolver({
|
|
58
|
+
path: "Query.dashboard",
|
|
59
|
+
dependencies: [],
|
|
60
|
+
resolver: ()=>()=>({})
|
|
61
|
+
});
|
|
62
|
+
builder.addResolver({
|
|
63
|
+
path: "Mutation.dashboard",
|
|
64
|
+
dependencies: [],
|
|
65
|
+
resolver: ()=>()=>({})
|
|
66
|
+
});
|
|
67
|
+
builder.addResolver({
|
|
68
|
+
path: "DashboardQuery.listDashboards",
|
|
69
|
+
dependencies: [
|
|
70
|
+
ListDashboardsUseCase
|
|
71
|
+
],
|
|
72
|
+
resolver (listDashboards) {
|
|
73
|
+
return async ()=>resolve(async ()=>{
|
|
74
|
+
const result = await listDashboards.execute();
|
|
75
|
+
if (result.isFail()) throw result.error;
|
|
76
|
+
return result.value;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
builder.addResolver({
|
|
81
|
+
path: "DashboardMutation.updateDashboard",
|
|
82
|
+
dependencies: [
|
|
83
|
+
UpdateDashboardUseCase
|
|
84
|
+
],
|
|
85
|
+
resolver (updateDashboard) {
|
|
86
|
+
return async ({ args })=>resolve(async ()=>{
|
|
87
|
+
const result = await updateDashboard.execute(args.data);
|
|
88
|
+
if (result.isFail()) throw result.error;
|
|
89
|
+
return result.value;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return builder;
|
|
94
|
+
}
|
|
95
|
+
constructor(){
|
|
96
|
+
this.getSchemaKey = staticSchemaKey("api-dashboard/DashboardGraphQLSchemaImpl");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const DashboardGraphQLSchema = CoreGraphQLSchemaFactory.createImplementation({
|
|
100
|
+
implementation: DashboardGraphQLSchemaImpl,
|
|
101
|
+
dependencies: []
|
|
102
|
+
});
|
|
103
|
+
export { DashboardGraphQLSchema };
|
|
104
|
+
|
|
105
|
+
//# sourceMappingURL=DashboardGraphQLSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/DashboardGraphQLSchema.js","sources":["../../src/graphql/DashboardGraphQLSchema.ts"],"sourcesContent":["import { resolve } from \"@webiny/api-graphql\";\nimport { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.js\";\nimport { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport { GraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ListDashboardsUseCase } from \"~/features/ListDashboards/abstractions.js\";\nimport { UpdateDashboardUseCase } from \"~/features/UpdateDashboard/abstractions.js\";\nimport type { DashboardLayout } from \"~/domain/types.js\";\n\nconst TYPE_DEFS = /* GraphQL */ `\n type Dashboard {\n columns: [[String!]!]!\n hidden: [String!]!\n columnCount: Int!\n }\n\n input DashboardInput {\n columns: [[String!]!]!\n hidden: [String!]!\n columnCount: Int!\n }\n\n type DashboardError {\n code: String\n message: String!\n data: JSON\n stack: String\n }\n\n type DashboardResponse {\n data: Dashboard\n error: DashboardError\n }\n\n type DashboardListResponse {\n data: [Dashboard!]\n error: DashboardError\n }\n\n type DashboardQuery {\n # The current identity's dashboards: empty until it customizes one, at most one for now.\n listDashboards: DashboardListResponse!\n }\n\n type DashboardMutation {\n # Creates the identity's dashboard on first use.\n updateDashboard(data: DashboardInput!): DashboardResponse!\n }\n\n extend type Query {\n dashboard: DashboardQuery\n }\n\n extend type Mutation {\n dashboard: DashboardMutation\n }\n`;\n\nclass DashboardGraphQLSchemaImpl implements CoreGraphQLSchemaFactory.Interface {\n public getSchemaKey = staticSchemaKey(\"api-dashboard/DashboardGraphQLSchemaImpl\");\n\n public async execute(builder: GraphQLSchemaBuilder.Interface): CoreGraphQLSchemaFactory.Return {\n builder.addTypeDefs(TYPE_DEFS);\n\n builder.addResolver({\n path: \"Query.dashboard\",\n dependencies: [],\n resolver: () => () => ({})\n });\n\n builder.addResolver({\n path: \"Mutation.dashboard\",\n dependencies: [],\n resolver: () => () => ({})\n });\n\n builder.addResolver({\n path: \"DashboardQuery.listDashboards\",\n dependencies: [ListDashboardsUseCase],\n resolver(listDashboards: ListDashboardsUseCase.Interface) {\n return async () => {\n return resolve(async () => {\n const result = await listDashboards.execute();\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n };\n }\n });\n\n builder.addResolver<{ data: DashboardLayout }>({\n path: \"DashboardMutation.updateDashboard\",\n dependencies: [UpdateDashboardUseCase],\n resolver(updateDashboard: UpdateDashboardUseCase.Interface) {\n return async ({ args }) => {\n return resolve(async () => {\n const result = await updateDashboard.execute(args.data);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n };\n }\n });\n\n return builder;\n }\n}\n\nexport const DashboardGraphQLSchema = CoreGraphQLSchemaFactory.createImplementation({\n implementation: DashboardGraphQLSchemaImpl,\n dependencies: []\n});\n"],"names":["TYPE_DEFS","DashboardGraphQLSchemaImpl","builder","ListDashboardsUseCase","listDashboards","resolve","result","UpdateDashboardUseCase","updateDashboard","args","staticSchemaKey","DashboardGraphQLSchema","CoreGraphQLSchemaFactory"],"mappings":";;;;;AAQA,MAAMA,YAA0B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CjC,CAAC;AAED,MAAMC;IAGF,MAAa,QAAQC,OAAuC,EAAmC;QAC3FA,QAAQ,WAAW,CAACF;QAEpBE,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc,EAAE;YAChB,UAAU,IAAM,IAAO,EAAC;QAC5B;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc,EAAE;YAChB,UAAU,IAAM,IAAO,EAAC;QAC5B;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACC;aAAsB;YACrC,UAASC,cAA+C;gBACpD,OAAO,UACIC,QAAQ;wBACX,MAAMC,SAAS,MAAMF,eAAe,OAAO;wBAC3C,IAAIE,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;wBAEtB,OAAOA,OAAO,KAAK;oBACvB;YAER;QACJ;QAEAJ,QAAQ,WAAW,CAA4B;YAC3C,MAAM;YACN,cAAc;gBAACK;aAAuB;YACtC,UAASC,eAAiD;gBACtD,OAAO,OAAO,EAAEC,IAAI,EAAE,GACXJ,QAAQ;wBACX,MAAMC,SAAS,MAAME,gBAAgB,OAAO,CAACC,KAAK,IAAI;wBACtD,IAAIH,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;wBAEtB,OAAOA,OAAO,KAAK;oBACvB;YAER;QACJ;QAEA,OAAOJ;IACX;;aAlDO,YAAY,GAAGQ,gBAAgB;;AAmD1C;AAEO,MAAMC,yBAAyBC,yBAAyB,oBAAoB,CAAC;IAChF,gBAAgBX;IAChB,cAAc,EAAE;AACpB"}
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DashboardAppFeature } from "./DashboardAppFeature.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@webiny/api-dashboard",
|
|
3
|
+
"version": "0.0.0-unstable.7c2def32a7",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/webiny/webiny-js.git"
|
|
12
|
+
},
|
|
13
|
+
"description": "Stores each admin user's dashboard layout.",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@webiny/api-core": "0.0.0-unstable.7c2def32a7",
|
|
17
|
+
"@webiny/api-graphql": "0.0.0-unstable.7c2def32a7",
|
|
18
|
+
"@webiny/feature": "0.0.0-unstable.7c2def32a7",
|
|
19
|
+
"zod": "4.4.3"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@webiny/api-core-testing": "0.0.0-unstable.7c2def32a7",
|
|
23
|
+
"@webiny/build-tools": "0.0.0-unstable.7c2def32a7",
|
|
24
|
+
"@webiny/event-handler-core": "0.0.0-unstable.7c2def32a7",
|
|
25
|
+
"graphql": "16.14.2",
|
|
26
|
+
"rimraf": "6.1.3",
|
|
27
|
+
"typescript": "7.0.2",
|
|
28
|
+
"vitest": "4.1.11"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"webiny": {
|
|
34
|
+
"publishFrom": "dist"
|
|
35
|
+
}
|
|
36
|
+
}
|