@maioradv/cms-basic-lib 1.0.0
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/README.md +6 -0
- package/dist/apitokens/graphql.d.ts +4 -0
- package/dist/apitokens/graphql.js +45 -0
- package/dist/apitokens/index.d.ts +14 -0
- package/dist/apitokens/index.js +31 -0
- package/dist/apitokens/types.d.ts +22 -0
- package/dist/apitokens/types.js +2 -0
- package/dist/auth/index.d.ts +7 -0
- package/dist/auth/index.js +15 -0
- package/dist/auth/types.d.ts +60 -0
- package/dist/auth/types.js +38 -0
- package/dist/client.d.ts +41 -0
- package/dist/client.js +60 -0
- package/dist/collections/graphql.d.ts +16 -0
- package/dist/collections/graphql.js +97 -0
- package/dist/collections/index.d.ts +26 -0
- package/dist/collections/index.js +62 -0
- package/dist/collections/types.d.ts +57 -0
- package/dist/collections/types.js +2 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +20 -0
- package/dist/configs/graphql.d.ts +4 -0
- package/dist/configs/graphql.js +86 -0
- package/dist/configs/index.d.ts +17 -0
- package/dist/configs/index.js +37 -0
- package/dist/configs/model.d.ts +5 -0
- package/dist/configs/model.js +2 -0
- package/dist/configs/services/ti-delizio.config.d.ts +18 -0
- package/dist/configs/services/ti-delizio.config.js +9 -0
- package/dist/configs/types.d.ts +23 -0
- package/dist/configs/types.js +2 -0
- package/dist/core/dto/clauses/index.d.ts +17 -0
- package/dist/core/dto/clauses/index.js +10 -0
- package/dist/core/dto/pagination/index.d.ts +37 -0
- package/dist/core/dto/pagination/index.js +6 -0
- package/dist/core/dto/sorting/index.d.ts +9 -0
- package/dist/core/dto/sorting/index.js +10 -0
- package/dist/core/model/remove-gql.response.d.ts +3 -0
- package/dist/core/model/remove-gql.response.js +2 -0
- package/dist/core/types/resolver.d.ts +12 -0
- package/dist/core/types/resolver.js +2 -0
- package/dist/core/utils/queryParams.d.ts +9 -0
- package/dist/core/utils/queryParams.js +14 -0
- package/dist/customers/types.d.ts +9 -0
- package/dist/customers/types.js +2 -0
- package/dist/error.d.ts +14 -0
- package/dist/error.js +39 -0
- package/dist/images/graphql.d.ts +4 -0
- package/dist/images/graphql.js +38 -0
- package/dist/images/index.d.ts +11 -0
- package/dist/images/index.js +27 -0
- package/dist/images/types.d.ts +29 -0
- package/dist/images/types.js +2 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +31 -0
- package/dist/io/index.d.ts +5 -0
- package/dist/io/index.js +13 -0
- package/dist/io/types.d.ts +4 -0
- package/dist/io/types.js +2 -0
- package/dist/languages/graphql.d.ts +4 -0
- package/dist/languages/graphql.js +51 -0
- package/dist/languages/index.d.ts +14 -0
- package/dist/languages/index.js +31 -0
- package/dist/languages/types.d.ts +29 -0
- package/dist/languages/types.js +2 -0
- package/dist/model.d.ts +25 -0
- package/dist/model.js +43 -0
- package/dist/popups/graphql.d.ts +4 -0
- package/dist/popups/graphql.js +54 -0
- package/dist/popups/index.d.ts +22 -0
- package/dist/popups/index.js +53 -0
- package/dist/popups/triggers.d.ts +6 -0
- package/dist/popups/triggers.js +12 -0
- package/dist/popups/types.d.ts +67 -0
- package/dist/popups/types.js +21 -0
- package/dist/productAttributes/graphql.d.ts +6 -0
- package/dist/productAttributes/graphql.js +103 -0
- package/dist/productAttributes/index.d.ts +16 -0
- package/dist/productAttributes/index.js +37 -0
- package/dist/productAttributes/types.d.ts +37 -0
- package/dist/productAttributes/types.js +2 -0
- package/dist/productAttributes/values.d.ts +11 -0
- package/dist/productAttributes/values.js +21 -0
- package/dist/products/graphql.d.ts +4 -0
- package/dist/products/graphql.js +56 -0
- package/dist/products/index.d.ts +26 -0
- package/dist/products/index.js +65 -0
- package/dist/products/types.d.ts +82 -0
- package/dist/products/types.js +2 -0
- package/dist/products/variants.d.ts +6 -0
- package/dist/products/variants.js +12 -0
- package/dist/roles/graphql.d.ts +4 -0
- package/dist/roles/graphql.js +50 -0
- package/dist/roles/index.d.ts +14 -0
- package/dist/roles/index.js +31 -0
- package/dist/roles/types.d.ts +25 -0
- package/dist/roles/types.js +2 -0
- package/dist/types.d.ts +30 -0
- package/dist/types.js +19 -0
- package/package.json +30 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const model_1 = require("../model");
|
|
4
|
+
const graphql_1 = require("./graphql");
|
|
5
|
+
class ProductAttributeValues extends model_1.ApiModule {
|
|
6
|
+
update(id, data) {
|
|
7
|
+
return this._call('patch', `/product-attribute-values/${id}`, data);
|
|
8
|
+
}
|
|
9
|
+
remove(id) {
|
|
10
|
+
return this._call('delete', `/product-attribute-values/${id}`);
|
|
11
|
+
}
|
|
12
|
+
list(args = {}) {
|
|
13
|
+
return this._graphql(graphql_1.ProductAttributeValuesResolvers.query.productAttributeValues, args);
|
|
14
|
+
}
|
|
15
|
+
removeMany(id) {
|
|
16
|
+
return this._graphql(graphql_1.ProductAttributeValuesResolvers.mutation.removeProductAttributeValues, {
|
|
17
|
+
id
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.default = ProductAttributeValues;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProductsResolvers = void 0;
|
|
4
|
+
exports.ProductsResolvers = {
|
|
5
|
+
query: {
|
|
6
|
+
products: {
|
|
7
|
+
name: 'products',
|
|
8
|
+
query: `query ProductList($limit: Int, $after: Int, $before: Int){
|
|
9
|
+
products(limit: $limit, after: $after, before: $before){
|
|
10
|
+
edges {
|
|
11
|
+
node {
|
|
12
|
+
id
|
|
13
|
+
}
|
|
14
|
+
cursor
|
|
15
|
+
}
|
|
16
|
+
nodes {
|
|
17
|
+
id
|
|
18
|
+
slug
|
|
19
|
+
title
|
|
20
|
+
subtitle
|
|
21
|
+
description
|
|
22
|
+
tags
|
|
23
|
+
translations {
|
|
24
|
+
key
|
|
25
|
+
locale
|
|
26
|
+
value
|
|
27
|
+
}
|
|
28
|
+
metafields {
|
|
29
|
+
key
|
|
30
|
+
value
|
|
31
|
+
}
|
|
32
|
+
published
|
|
33
|
+
createdAt
|
|
34
|
+
updatedAt
|
|
35
|
+
}
|
|
36
|
+
meta {
|
|
37
|
+
startCursor
|
|
38
|
+
endCursor
|
|
39
|
+
hasNextPage
|
|
40
|
+
hasPreviousPage
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}`,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
mutation: {
|
|
47
|
+
removeProducts: {
|
|
48
|
+
name: 'removeProducts',
|
|
49
|
+
query: `mutation ProductDelete($id: [Int!]!){
|
|
50
|
+
removeProducts(id: $id) {
|
|
51
|
+
count
|
|
52
|
+
}
|
|
53
|
+
}`,
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PaginatedDto, PaginatedGQL } from "../core/dto/pagination";
|
|
2
|
+
import { RemoveGQL } from "../core/model/remove-gql.response";
|
|
3
|
+
import { Image } from "../images/types";
|
|
4
|
+
import { RestApiModuleI, ApiModule, GraphApiModuleI } from "../model";
|
|
5
|
+
import { CreateCollectionOnProductDto, CreateProductAttributeValueProductDto, CreateProductDto, CreateProductImageDto, CreateProductVariantDto, FindAllProductDto, FindOneProductDto, Product, ProductAttributeValueProduct, ProductCollection, ProductImage, ProductVariant, QueryProductDto, UpdateProductDto, UpdateProductImageDto } from "../products/types";
|
|
6
|
+
import { WithRelation } from "../types";
|
|
7
|
+
import { QueryProductGQLDto } from "./graphql";
|
|
8
|
+
export default class Products extends ApiModule implements RestApiModuleI, GraphApiModuleI {
|
|
9
|
+
create(args: CreateProductDto): Promise<Product>;
|
|
10
|
+
findAll(args?: QueryProductDto): Promise<PaginatedDto<FindAllProductDto>>;
|
|
11
|
+
findOne(id: number): Promise<FindOneProductDto>;
|
|
12
|
+
update(id: number, data: UpdateProductDto): Promise<Product>;
|
|
13
|
+
remove(id: number): Promise<Product>;
|
|
14
|
+
list(args?: QueryProductGQLDto): Promise<PaginatedGQL<Product>>;
|
|
15
|
+
removeMany(id: number | number[]): Promise<RemoveGQL>;
|
|
16
|
+
createImage(productId: number, args: CreateProductImageDto): Promise<ProductImage>;
|
|
17
|
+
findAllImages(productId: number): Promise<WithRelation<ProductImage, 'Image', Image>[]>;
|
|
18
|
+
updateImage(productId: number, imageId: number, data: UpdateProductImageDto): Promise<ProductImage>;
|
|
19
|
+
removeImage(productId: number, imageId: number): Promise<ProductImage>;
|
|
20
|
+
linkCollection(productId: number, args: CreateCollectionOnProductDto): Promise<ProductCollection>;
|
|
21
|
+
unlinkCollection(productId: number, collectionId: number): Promise<ProductCollection>;
|
|
22
|
+
createVariant(productId: number, args: CreateProductVariantDto): Promise<ProductVariant>;
|
|
23
|
+
findAllVariants(productId: number): Promise<ProductVariant[]>;
|
|
24
|
+
linkAttributeValue(productId: number, args: CreateProductAttributeValueProductDto): Promise<ProductAttributeValueProduct>;
|
|
25
|
+
unlinkAttributeValue(productId: number, attributeValueId: number): Promise<ProductAttributeValueProduct>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const queryParams_1 = require("../core/utils/queryParams");
|
|
4
|
+
const model_1 = require("../model");
|
|
5
|
+
const graphql_1 = require("./graphql");
|
|
6
|
+
class Products extends model_1.ApiModule {
|
|
7
|
+
create(args) {
|
|
8
|
+
return this._call('post', '/products', args);
|
|
9
|
+
}
|
|
10
|
+
findAll(args = {}) {
|
|
11
|
+
return this._call('get', '/products', (0, queryParams_1.queryParams)(args));
|
|
12
|
+
}
|
|
13
|
+
findOne(id) {
|
|
14
|
+
return this._call('get', `/products/${id}`);
|
|
15
|
+
}
|
|
16
|
+
update(id, data) {
|
|
17
|
+
return this._call('patch', `/products/${id}`, data);
|
|
18
|
+
}
|
|
19
|
+
remove(id) {
|
|
20
|
+
return this._call('delete', `/products/${id}`);
|
|
21
|
+
}
|
|
22
|
+
list(args = {}) {
|
|
23
|
+
return this._graphql(graphql_1.ProductsResolvers.query.products, args);
|
|
24
|
+
}
|
|
25
|
+
removeMany(id) {
|
|
26
|
+
return this._graphql(graphql_1.ProductsResolvers.mutation.removeProducts, {
|
|
27
|
+
id
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
createImage(productId, args) {
|
|
31
|
+
return this._call('post', `/products/${productId}/images`, args, {
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'multipart/form-data'
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
findAllImages(productId) {
|
|
38
|
+
return this._call('get', `/products/${productId}/images`);
|
|
39
|
+
}
|
|
40
|
+
updateImage(productId, imageId, data) {
|
|
41
|
+
return this._call('patch', `/products/${productId}/images/${imageId}`, data);
|
|
42
|
+
}
|
|
43
|
+
removeImage(productId, imageId) {
|
|
44
|
+
return this._call('delete', `/products/${productId}/images/${imageId}`);
|
|
45
|
+
}
|
|
46
|
+
linkCollection(productId, args) {
|
|
47
|
+
return this._call('post', `/products/${productId}/collections`, args);
|
|
48
|
+
}
|
|
49
|
+
unlinkCollection(productId, collectionId) {
|
|
50
|
+
return this._call('delete', `/products/${productId}/collections/${collectionId}`);
|
|
51
|
+
}
|
|
52
|
+
createVariant(productId, args) {
|
|
53
|
+
return this._call('post', `/products/${productId}/variants`, args);
|
|
54
|
+
}
|
|
55
|
+
findAllVariants(productId) {
|
|
56
|
+
return this._call('get', `/products/${productId}/variants`);
|
|
57
|
+
}
|
|
58
|
+
linkAttributeValue(productId, args) {
|
|
59
|
+
return this._call('post', `/products/${productId}/attribute-values`, args);
|
|
60
|
+
}
|
|
61
|
+
unlinkAttributeValue(productId, attributeValueId) {
|
|
62
|
+
return this._call('delete', `/products/${productId}/attribute-values/${attributeValueId}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.default = Products;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { BooleanClause, NumberClause, StringClause, WhereClausesDto } from "../core/dto/clauses";
|
|
2
|
+
import { Sorting, SortingParamsDto } from "../core/dto/sorting";
|
|
3
|
+
import { QueryParamsDto } from "../core/utils/queryParams";
|
|
4
|
+
import { CreateImageDto, Image } from "../images/types";
|
|
5
|
+
import { ProductAttributeValue } from "../productAttributes/types";
|
|
6
|
+
import { Metafield, OmitRequire, Translation, WithRelation, WithRelations } from "../types";
|
|
7
|
+
export type Product = {
|
|
8
|
+
id: number;
|
|
9
|
+
slug: string;
|
|
10
|
+
title: string;
|
|
11
|
+
subtitle: string | null;
|
|
12
|
+
description: string | null;
|
|
13
|
+
tags: string[];
|
|
14
|
+
translations: Translation[];
|
|
15
|
+
metafields: Metafield[];
|
|
16
|
+
published: boolean;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
updatedAt: Date;
|
|
19
|
+
};
|
|
20
|
+
export type ProductVariant = {
|
|
21
|
+
id: number;
|
|
22
|
+
description: string | null;
|
|
23
|
+
translations: Translation[];
|
|
24
|
+
price: number | null;
|
|
25
|
+
fullPrice: number | null;
|
|
26
|
+
productId: number;
|
|
27
|
+
published: boolean;
|
|
28
|
+
createdAt: Date;
|
|
29
|
+
updatedAt: Date;
|
|
30
|
+
};
|
|
31
|
+
export type ProductCollection = {
|
|
32
|
+
productId: number;
|
|
33
|
+
collectionId: number;
|
|
34
|
+
position: number | null;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
};
|
|
38
|
+
export type ProductImage = {
|
|
39
|
+
productId: number;
|
|
40
|
+
imageId: number;
|
|
41
|
+
locale: string | null;
|
|
42
|
+
position: number | null;
|
|
43
|
+
createdAt: Date;
|
|
44
|
+
updatedAt: Date;
|
|
45
|
+
};
|
|
46
|
+
export type ProductAttributeValueProduct = {
|
|
47
|
+
productId: number;
|
|
48
|
+
productAttributeValueId: number;
|
|
49
|
+
position: number | null;
|
|
50
|
+
createdAt: Date;
|
|
51
|
+
updatedAt: Date;
|
|
52
|
+
};
|
|
53
|
+
export type CreateProductCollectionDto = OmitRequire<ProductCollection, 'createdAt' | 'updatedAt', 'collectionId' | 'productId'>;
|
|
54
|
+
export type CreateProductDto = OmitRequire<Product, 'id' | 'createdAt' | 'updatedAt' | 'slug', 'title'> & {
|
|
55
|
+
attributes?: number[];
|
|
56
|
+
variants?: CreateProductVariantDto[];
|
|
57
|
+
};
|
|
58
|
+
export type UpdateProductDto = Partial<Omit<CreateProductDto, 'variants' | 'attributes'>>;
|
|
59
|
+
export type CreateProductImageDto = OmitRequire<ProductImage, 'productId' | 'createdAt' | 'updatedAt' | 'imageId'> & CreateImageDto;
|
|
60
|
+
export type UpdateProductImageDto = Omit<CreateProductImageDto, 'file'>;
|
|
61
|
+
export type CreateProductVariantDto = OmitRequire<ProductVariant, 'id' | 'createdAt' | 'updatedAt' | 'productId'>;
|
|
62
|
+
export type UpdateProductVariantDto = Partial<CreateProductVariantDto>;
|
|
63
|
+
export type CreateCollectionOnProductDto = Omit<CreateProductCollectionDto, 'productId'>;
|
|
64
|
+
export type CreateProductAttributeValueProductDto = OmitRequire<ProductAttributeValueProduct, 'productId' | 'createdAt' | 'updatedAt' | 'position'>;
|
|
65
|
+
export type FindAllProductDto = WithRelation<Product, 'ProductImage', WithRelation<ProductImage, 'Image', Image>[]>;
|
|
66
|
+
export type FindOneProductDto = WithRelations<Product, {
|
|
67
|
+
attributes: WithRelation<ProductAttributeValueProduct, 'ProductAttributeValue', ProductAttributeValue>[];
|
|
68
|
+
ProductVariant: ProductVariant[];
|
|
69
|
+
}>;
|
|
70
|
+
export type SortingProductDto = SortingParamsDto<{
|
|
71
|
+
title?: Sorting;
|
|
72
|
+
published?: Sorting;
|
|
73
|
+
}>;
|
|
74
|
+
export type ClausesProductDto = WhereClausesDto<{
|
|
75
|
+
title?: StringClause;
|
|
76
|
+
subtitle?: StringClause;
|
|
77
|
+
description?: StringClause;
|
|
78
|
+
collectionId?: NumberClause;
|
|
79
|
+
productAttributeValueId?: NumberClause;
|
|
80
|
+
published?: BooleanClause;
|
|
81
|
+
}>;
|
|
82
|
+
export type QueryProductDto = QueryParamsDto<SortingProductDto, ClausesProductDto>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ApiModule } from "../model";
|
|
2
|
+
import { ProductVariant, UpdateProductVariantDto } from "../products/types";
|
|
3
|
+
export default class ProductVariants extends ApiModule {
|
|
4
|
+
update(id: number, data: UpdateProductVariantDto): Promise<ProductVariant>;
|
|
5
|
+
remove(id: number): Promise<ProductVariant>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const model_1 = require("../model");
|
|
4
|
+
class ProductVariants extends model_1.ApiModule {
|
|
5
|
+
update(id, data) {
|
|
6
|
+
return this._call('patch', `/product-variants/${id}`, data);
|
|
7
|
+
}
|
|
8
|
+
remove(id) {
|
|
9
|
+
return this._call('delete', `/product-variants/${id}`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = ProductVariants;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RolesResolvers = void 0;
|
|
4
|
+
exports.RolesResolvers = {
|
|
5
|
+
query: {
|
|
6
|
+
roles: {
|
|
7
|
+
name: 'roles',
|
|
8
|
+
query: `query RoleList($limit: Int, $after: Int, $before: Int){
|
|
9
|
+
roles(limit: $limit, after: $after, before: $before){
|
|
10
|
+
edges {
|
|
11
|
+
node {
|
|
12
|
+
id
|
|
13
|
+
}
|
|
14
|
+
cursor
|
|
15
|
+
}
|
|
16
|
+
nodes {
|
|
17
|
+
id
|
|
18
|
+
name
|
|
19
|
+
description
|
|
20
|
+
permissions
|
|
21
|
+
readonly
|
|
22
|
+
translations {
|
|
23
|
+
key
|
|
24
|
+
locale
|
|
25
|
+
value
|
|
26
|
+
}
|
|
27
|
+
createdAt
|
|
28
|
+
updatedAt
|
|
29
|
+
}
|
|
30
|
+
meta {
|
|
31
|
+
startCursor
|
|
32
|
+
endCursor
|
|
33
|
+
hasNextPage
|
|
34
|
+
hasPreviousPage
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}`,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
mutation: {
|
|
41
|
+
removeRoles: {
|
|
42
|
+
name: 'removeRoles',
|
|
43
|
+
query: `mutation RoleDelete($id: [Int!]!){
|
|
44
|
+
removeRoles(id: $id) {
|
|
45
|
+
count
|
|
46
|
+
}
|
|
47
|
+
}`,
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PaginatedDto, PaginatedGQL } from "../core/dto/pagination";
|
|
2
|
+
import { RemoveGQL } from "../core/model/remove-gql.response";
|
|
3
|
+
import { RestApiModuleI, ApiModule, GraphApiModuleI } from "../model";
|
|
4
|
+
import { QueryRoleGQLDto } from "./graphql";
|
|
5
|
+
import { CreateRoleDto, QueryRoleDto, Role, UpdateRoleDto } from "./types";
|
|
6
|
+
export default class Roles extends ApiModule implements RestApiModuleI, GraphApiModuleI {
|
|
7
|
+
create(args: CreateRoleDto): Promise<Role>;
|
|
8
|
+
findAll(args?: QueryRoleDto): Promise<PaginatedDto<Role>>;
|
|
9
|
+
findOne(id: number): Promise<Role>;
|
|
10
|
+
update(id: number, data: UpdateRoleDto): Promise<Role>;
|
|
11
|
+
remove(id: number): Promise<Role>;
|
|
12
|
+
list(args?: QueryRoleGQLDto): Promise<PaginatedGQL<Role>>;
|
|
13
|
+
removeMany(id: number | number[]): Promise<RemoveGQL>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const queryParams_1 = require("../core/utils/queryParams");
|
|
4
|
+
const model_1 = require("../model");
|
|
5
|
+
const graphql_1 = require("./graphql");
|
|
6
|
+
class Roles extends model_1.ApiModule {
|
|
7
|
+
create(args) {
|
|
8
|
+
return this._call('post', '/roles', args);
|
|
9
|
+
}
|
|
10
|
+
findAll(args = {}) {
|
|
11
|
+
return this._call('get', '/roles', (0, queryParams_1.queryParams)(args));
|
|
12
|
+
}
|
|
13
|
+
findOne(id) {
|
|
14
|
+
return this._call('get', `/roles/${id}`);
|
|
15
|
+
}
|
|
16
|
+
update(id, data) {
|
|
17
|
+
return this._call('patch', `/roles/${id}`, data);
|
|
18
|
+
}
|
|
19
|
+
remove(id) {
|
|
20
|
+
return this._call('delete', `/roles/${id}`);
|
|
21
|
+
}
|
|
22
|
+
list(args = {}) {
|
|
23
|
+
return this._graphql(graphql_1.RolesResolvers.query.roles, args);
|
|
24
|
+
}
|
|
25
|
+
removeMany(id) {
|
|
26
|
+
return this._graphql(graphql_1.RolesResolvers.mutation.removeRoles, {
|
|
27
|
+
id
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.default = Roles;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Permission } from "../auth/types";
|
|
2
|
+
import { StringClause, WhereClausesDto } from "../core/dto/clauses";
|
|
3
|
+
import { Sorting, SortingParamsDto } from "../core/dto/sorting";
|
|
4
|
+
import { QueryParamsDto } from "../core/utils/queryParams";
|
|
5
|
+
import { OmitRequire, Translation } from "../types";
|
|
6
|
+
export type Role = {
|
|
7
|
+
id: number;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string | null;
|
|
10
|
+
permissions: Permission[];
|
|
11
|
+
readOnly: boolean;
|
|
12
|
+
translations: Translation[];
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
updatedAt: Date;
|
|
15
|
+
};
|
|
16
|
+
export type CreateRoleDto = OmitRequire<Role, 'id' | 'createdAt' | 'updatedAt' | 'readOnly', 'name' | 'permissions'>;
|
|
17
|
+
export type UpdateRoleDto = Partial<CreateRoleDto>;
|
|
18
|
+
export type SortingRoleDto = SortingParamsDto<{
|
|
19
|
+
name?: Sorting;
|
|
20
|
+
}>;
|
|
21
|
+
export type ClausesRoleDto = WhereClausesDto<{
|
|
22
|
+
name?: StringClause;
|
|
23
|
+
description?: StringClause;
|
|
24
|
+
}>;
|
|
25
|
+
export type QueryRoleDto = QueryParamsDto<SortingRoleDto, ClausesRoleDto>;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare enum ApiVersion {
|
|
2
|
+
July24 = "2024-07",
|
|
3
|
+
Unstable = "unstable"
|
|
4
|
+
}
|
|
5
|
+
export declare const LATEST_API_VERSION = ApiVersion.July24;
|
|
6
|
+
export declare const SUPPORTED_API_VERSIONS: ApiVersion[];
|
|
7
|
+
export declare enum ApiHeader {
|
|
8
|
+
Authorization = "Authorization",
|
|
9
|
+
ApiVersion = "X-Api-Version",
|
|
10
|
+
ApiCacheControl = "X-Api-Cache-Control"
|
|
11
|
+
}
|
|
12
|
+
export type Metafield = {
|
|
13
|
+
key: string;
|
|
14
|
+
value: string;
|
|
15
|
+
};
|
|
16
|
+
export type Translation = {
|
|
17
|
+
key: string;
|
|
18
|
+
value: string;
|
|
19
|
+
locale: string;
|
|
20
|
+
};
|
|
21
|
+
export type WithRelation<T, R extends string, RType> = T & {
|
|
22
|
+
[key in R]: RType;
|
|
23
|
+
};
|
|
24
|
+
export type WithRelations<T, R extends object> = T & R;
|
|
25
|
+
export type WithRequired<T, K extends keyof T> = T & {
|
|
26
|
+
[P in K]-?: T[P];
|
|
27
|
+
};
|
|
28
|
+
export type OmitRequire<T, O extends keyof T = null, R extends keyof T = null> = Partial<Omit<T, O>> & {
|
|
29
|
+
[P in R]-?: T[P];
|
|
30
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiHeader = exports.SUPPORTED_API_VERSIONS = exports.LATEST_API_VERSION = exports.ApiVersion = void 0;
|
|
4
|
+
var ApiVersion;
|
|
5
|
+
(function (ApiVersion) {
|
|
6
|
+
ApiVersion["July24"] = "2024-07";
|
|
7
|
+
ApiVersion["Unstable"] = "unstable";
|
|
8
|
+
})(ApiVersion || (exports.ApiVersion = ApiVersion = {}));
|
|
9
|
+
exports.LATEST_API_VERSION = ApiVersion.July24;
|
|
10
|
+
exports.SUPPORTED_API_VERSIONS = [
|
|
11
|
+
exports.LATEST_API_VERSION,
|
|
12
|
+
ApiVersion.Unstable
|
|
13
|
+
];
|
|
14
|
+
var ApiHeader;
|
|
15
|
+
(function (ApiHeader) {
|
|
16
|
+
ApiHeader["Authorization"] = "Authorization";
|
|
17
|
+
ApiHeader["ApiVersion"] = "X-Api-Version";
|
|
18
|
+
ApiHeader["ApiCacheControl"] = "X-Api-Cache-Control";
|
|
19
|
+
})(ApiHeader || (exports.ApiHeader = ApiHeader = {}));
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maioradv/cms-basic-lib",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "JS lib for Maior CMS Basic Api",
|
|
5
|
+
"repository": "https://github.com/maioradv/cms-basic-lib.git",
|
|
6
|
+
"author": "Maior ADV Srl",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"private": false,
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"/dist"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"example": "ts-node example/test.ts",
|
|
16
|
+
"build": "tsc"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"axios": "^1.7.2"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^20.14.9",
|
|
23
|
+
"ts-node": "^10.9.2",
|
|
24
|
+
"typescript": "^5.5.3"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"typescript",
|
|
28
|
+
"maior"
|
|
29
|
+
]
|
|
30
|
+
}
|