@jwork-space/strapi-sdk 1.0.3 → 1.0.5
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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -8
- package/dist/index.mjs +11 -8
- package/package.json +64 -65
package/dist/index.d.mts
CHANGED
|
@@ -115,11 +115,11 @@ declare class StrapiSDK<T extends BaseModel> extends BaseAPI<T> {
|
|
|
115
115
|
private config;
|
|
116
116
|
constructor(resource: string, config?: StrapiConfig);
|
|
117
117
|
exist: (opt: RequestOptions<T>) => Promise<boolean>;
|
|
118
|
-
protected getQueryParams(opt?: RequestOptions<T
|
|
118
|
+
protected getQueryParams(opt?: RequestOptions<T>, excludePagination?: boolean): AnyObject & {
|
|
119
119
|
filters?: AnyObject;
|
|
120
120
|
};
|
|
121
121
|
protected normalizeBody(model: T, action: "save" | "update", { multipart, transformModel }: RequestOptions<T>, serializeOptions?: SerializeOptions): AnyObject | FormData;
|
|
122
|
-
protected getRequestParams(opt?: RequestOptions<T
|
|
122
|
+
protected getRequestParams(opt?: RequestOptions<T>, excludePagination?: boolean): RequestData;
|
|
123
123
|
requestExecutor({ uri, data }: {
|
|
124
124
|
uri: string;
|
|
125
125
|
data: RequestData;
|
package/dist/index.d.ts
CHANGED
|
@@ -115,11 +115,11 @@ declare class StrapiSDK<T extends BaseModel> extends BaseAPI<T> {
|
|
|
115
115
|
private config;
|
|
116
116
|
constructor(resource: string, config?: StrapiConfig);
|
|
117
117
|
exist: (opt: RequestOptions<T>) => Promise<boolean>;
|
|
118
|
-
protected getQueryParams(opt?: RequestOptions<T
|
|
118
|
+
protected getQueryParams(opt?: RequestOptions<T>, excludePagination?: boolean): AnyObject & {
|
|
119
119
|
filters?: AnyObject;
|
|
120
120
|
};
|
|
121
121
|
protected normalizeBody(model: T, action: "save" | "update", { multipart, transformModel }: RequestOptions<T>, serializeOptions?: SerializeOptions): AnyObject | FormData;
|
|
122
|
-
protected getRequestParams(opt?: RequestOptions<T
|
|
122
|
+
protected getRequestParams(opt?: RequestOptions<T>, excludePagination?: boolean): RequestData;
|
|
123
123
|
requestExecutor({ uri, data }: {
|
|
124
124
|
uri: string;
|
|
125
125
|
data: RequestData;
|
package/dist/index.js
CHANGED
|
@@ -489,7 +489,8 @@ var StrapiSDK = class extends BaseAPI {
|
|
|
489
489
|
this.findById = async (id, opt) => {
|
|
490
490
|
const uri = `${opt?.url ?? this.endpoint}/${id}`;
|
|
491
491
|
if (opt) delete opt.sort;
|
|
492
|
-
const
|
|
492
|
+
const parameters = this.getRequestParams(opt, true);
|
|
493
|
+
const { data } = opt?.method === "get" ? await this.getCall(uri, parameters) : await this.postCall(uri, parameters);
|
|
493
494
|
return data;
|
|
494
495
|
};
|
|
495
496
|
this.useListAll = (opt) => {
|
|
@@ -719,12 +720,14 @@ var StrapiSDK = class extends BaseAPI {
|
|
|
719
720
|
baseURL
|
|
720
721
|
};
|
|
721
722
|
}
|
|
722
|
-
getQueryParams(opt) {
|
|
723
|
+
getQueryParams(opt, excludePagination = false) {
|
|
723
724
|
const query = {
|
|
724
725
|
sort: opt?.sort || "id:asc",
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
726
|
+
...excludePagination ? {} : {
|
|
727
|
+
pagination: {
|
|
728
|
+
page: opt?.pagination?.page || 1,
|
|
729
|
+
pageSize: opt?.pagination?.pageSize || this.config.pageSize
|
|
730
|
+
}
|
|
728
731
|
}
|
|
729
732
|
};
|
|
730
733
|
if (opt?.populate) query.populate = opt.populate;
|
|
@@ -741,10 +744,10 @@ var StrapiSDK = class extends BaseAPI {
|
|
|
741
744
|
const body = this.serialize(data, serializeOptions);
|
|
742
745
|
return this.config.wrapBodyInData ? { data: body } : body;
|
|
743
746
|
}
|
|
744
|
-
getRequestParams(opt) {
|
|
747
|
+
getRequestParams(opt, excludePagination = false) {
|
|
745
748
|
const options = {
|
|
746
749
|
auth: opt?.auth ?? true,
|
|
747
|
-
query: this.getQueryParams(opt)
|
|
750
|
+
query: this.getQueryParams(opt, excludePagination)
|
|
748
751
|
};
|
|
749
752
|
return options;
|
|
750
753
|
}
|
|
@@ -797,7 +800,7 @@ var StrapiSDK = class extends BaseAPI {
|
|
|
797
800
|
getInvalidateKeys(method, opt) {
|
|
798
801
|
const defaultKeys = this.defaultInvalidateKeys?.[method] ?? [[]];
|
|
799
802
|
const extraKeys = opt?.invalidateKeys ?? [];
|
|
800
|
-
return [...defaultKeys, ...extraKeys
|
|
803
|
+
return [...defaultKeys, ...extraKeys];
|
|
801
804
|
}
|
|
802
805
|
async findOrCreate(data, optFind, optPayload, serializeOptionsPayload) {
|
|
803
806
|
const exist = await this.finOneEntity(optFind);
|
package/dist/index.mjs
CHANGED
|
@@ -440,7 +440,8 @@ var StrapiSDK = class extends BaseAPI {
|
|
|
440
440
|
this.findById = async (id, opt) => {
|
|
441
441
|
const uri = `${opt?.url ?? this.endpoint}/${id}`;
|
|
442
442
|
if (opt) delete opt.sort;
|
|
443
|
-
const
|
|
443
|
+
const parameters = this.getRequestParams(opt, true);
|
|
444
|
+
const { data } = opt?.method === "get" ? await this.getCall(uri, parameters) : await this.postCall(uri, parameters);
|
|
444
445
|
return data;
|
|
445
446
|
};
|
|
446
447
|
this.useListAll = (opt) => {
|
|
@@ -670,12 +671,14 @@ var StrapiSDK = class extends BaseAPI {
|
|
|
670
671
|
baseURL
|
|
671
672
|
};
|
|
672
673
|
}
|
|
673
|
-
getQueryParams(opt) {
|
|
674
|
+
getQueryParams(opt, excludePagination = false) {
|
|
674
675
|
const query = {
|
|
675
676
|
sort: opt?.sort || "id:asc",
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
677
|
+
...excludePagination ? {} : {
|
|
678
|
+
pagination: {
|
|
679
|
+
page: opt?.pagination?.page || 1,
|
|
680
|
+
pageSize: opt?.pagination?.pageSize || this.config.pageSize
|
|
681
|
+
}
|
|
679
682
|
}
|
|
680
683
|
};
|
|
681
684
|
if (opt?.populate) query.populate = opt.populate;
|
|
@@ -692,10 +695,10 @@ var StrapiSDK = class extends BaseAPI {
|
|
|
692
695
|
const body = this.serialize(data, serializeOptions);
|
|
693
696
|
return this.config.wrapBodyInData ? { data: body } : body;
|
|
694
697
|
}
|
|
695
|
-
getRequestParams(opt) {
|
|
698
|
+
getRequestParams(opt, excludePagination = false) {
|
|
696
699
|
const options = {
|
|
697
700
|
auth: opt?.auth ?? true,
|
|
698
|
-
query: this.getQueryParams(opt)
|
|
701
|
+
query: this.getQueryParams(opt, excludePagination)
|
|
699
702
|
};
|
|
700
703
|
return options;
|
|
701
704
|
}
|
|
@@ -748,7 +751,7 @@ var StrapiSDK = class extends BaseAPI {
|
|
|
748
751
|
getInvalidateKeys(method, opt) {
|
|
749
752
|
const defaultKeys = this.defaultInvalidateKeys?.[method] ?? [[]];
|
|
750
753
|
const extraKeys = opt?.invalidateKeys ?? [];
|
|
751
|
-
return [...defaultKeys, ...extraKeys
|
|
754
|
+
return [...defaultKeys, ...extraKeys];
|
|
752
755
|
}
|
|
753
756
|
async findOrCreate(data, optFind, optPayload, serializeOptionsPayload) {
|
|
754
757
|
const exist = await this.finOneEntity(optFind);
|
package/package.json
CHANGED
|
@@ -1,67 +1,66 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"assets": [
|
|
56
|
-
"package.json"
|
|
57
|
-
],
|
|
58
|
-
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
"files": [
|
|
64
|
-
"dist",
|
|
65
|
-
"README.md"
|
|
2
|
+
"name": "@jwork-space/strapi-sdk",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "SDK para Strapi con soporte para React Query y TypeScript",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"author": "Roman Ernesto Gonzalez Alas, Jonathan Fernando González Ramos",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://gitlab.com/Jona11/strapi-sdk"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18.0.0"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@tanstack/react-query": ">=5.90.0",
|
|
22
|
+
"antd": ">=5.0.0",
|
|
23
|
+
"axios": ">=1.7.0",
|
|
24
|
+
"dayjs": ">=1.11.10",
|
|
25
|
+
"qs": ">=6.11.0",
|
|
26
|
+
"react": ">=18.0.0",
|
|
27
|
+
"react-dom": ">=18.0.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@semantic-release/git": "^10.0.1",
|
|
31
|
+
"@semantic-release/gitlab": "^13.2.9",
|
|
32
|
+
"@semantic-release/npm": "^13.1.2",
|
|
33
|
+
"@types/qs": "^6.14.0",
|
|
34
|
+
"@types/react": "^19.2.2",
|
|
35
|
+
"@types/react-dom": "^19.2.2",
|
|
36
|
+
"semantic-release": "^25.0.2",
|
|
37
|
+
"tsup": "^8.5.0",
|
|
38
|
+
"typescript": "^5.9.3"
|
|
39
|
+
},
|
|
40
|
+
"release": {
|
|
41
|
+
"plugins": [
|
|
42
|
+
"@semantic-release/commit-analyzer",
|
|
43
|
+
"@semantic-release/release-notes-generator",
|
|
44
|
+
"@semantic-release/npm",
|
|
45
|
+
"@semantic-release/gitlab",
|
|
46
|
+
[
|
|
47
|
+
"@semantic-release/git",
|
|
48
|
+
{
|
|
49
|
+
"assets": [
|
|
50
|
+
"package.json"
|
|
51
|
+
],
|
|
52
|
+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
66
55
|
]
|
|
67
|
-
}
|
|
56
|
+
},
|
|
57
|
+
"files": [
|
|
58
|
+
"dist",
|
|
59
|
+
"README.md"
|
|
60
|
+
],
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
63
|
+
"dev": "tsup src/index.ts --format esm,cjs --dts --watch",
|
|
64
|
+
"semantic-release": "semantic-release"
|
|
65
|
+
}
|
|
66
|
+
}
|