@malevich-studio/strapi-sdk-typescript 1.2.2 → 1.2.3
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/cli.cjs +20 -0
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +20 -0
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +16 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.mjs +16 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -20104,6 +20104,9 @@ class Strapi {
|
|
|
20104
20104
|
this.token = token;
|
|
20105
20105
|
}
|
|
20106
20106
|
async fetch(endpoint, data = {}, params = {}) {
|
|
20107
|
+
return await this.fetchData(endpoint, data, params);
|
|
20108
|
+
}
|
|
20109
|
+
async fetchData(endpoint, data = {}, params = {}) {
|
|
20107
20110
|
const queryString = params.method === 'GET' ? qs.stringify(data) : '';
|
|
20108
20111
|
return await this.baseFetch(queryString ? `${endpoint}?${queryString}` : endpoint, _.merge({
|
|
20109
20112
|
headers: {
|
|
@@ -20116,6 +20119,19 @@ class Strapi {
|
|
|
20116
20119
|
} : {}),
|
|
20117
20120
|
}, params));
|
|
20118
20121
|
}
|
|
20122
|
+
setToken(token) {
|
|
20123
|
+
this.token = token;
|
|
20124
|
+
}
|
|
20125
|
+
async baseLogin(identifier, password) {
|
|
20126
|
+
const response = await this.fetchData('/auth/local', {
|
|
20127
|
+
identifier,
|
|
20128
|
+
password
|
|
20129
|
+
}, {
|
|
20130
|
+
method: 'POST',
|
|
20131
|
+
});
|
|
20132
|
+
this.setToken(response.jwt);
|
|
20133
|
+
return response.user;
|
|
20134
|
+
}
|
|
20119
20135
|
async getLocales(params) {
|
|
20120
20136
|
return await this.baseFetch('i18n/locales', _.merge({
|
|
20121
20137
|
headers: {
|
|
@@ -20732,6 +20748,10 @@ async function generateStrapiTypes(strapi) {
|
|
|
20732
20748
|
'import {BlocksContent} from "@strapi/blocks-react-renderer";',
|
|
20733
20749
|
'',
|
|
20734
20750
|
'export default class Strapi extends StrapiBase {',
|
|
20751
|
+
` public async login(identifier: string, password: string) {`,
|
|
20752
|
+
` return await this.baseLogin<User>(identifier, password);`,
|
|
20753
|
+
' }',
|
|
20754
|
+
'',
|
|
20735
20755
|
methods.join('\n\n'),
|
|
20736
20756
|
'}',
|
|
20737
20757
|
'',
|