@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.mjs
CHANGED
|
@@ -20084,6 +20084,9 @@ class Strapi {
|
|
|
20084
20084
|
this.token = token;
|
|
20085
20085
|
}
|
|
20086
20086
|
async fetch(endpoint, data = {}, params = {}) {
|
|
20087
|
+
return await this.fetchData(endpoint, data, params);
|
|
20088
|
+
}
|
|
20089
|
+
async fetchData(endpoint, data = {}, params = {}) {
|
|
20087
20090
|
const queryString = params.method === 'GET' ? qs.stringify(data) : '';
|
|
20088
20091
|
return await this.baseFetch(queryString ? `${endpoint}?${queryString}` : endpoint, _.merge({
|
|
20089
20092
|
headers: {
|
|
@@ -20096,6 +20099,19 @@ class Strapi {
|
|
|
20096
20099
|
} : {}),
|
|
20097
20100
|
}, params));
|
|
20098
20101
|
}
|
|
20102
|
+
setToken(token) {
|
|
20103
|
+
this.token = token;
|
|
20104
|
+
}
|
|
20105
|
+
async baseLogin(identifier, password) {
|
|
20106
|
+
const response = await this.fetchData('/auth/local', {
|
|
20107
|
+
identifier,
|
|
20108
|
+
password
|
|
20109
|
+
}, {
|
|
20110
|
+
method: 'POST',
|
|
20111
|
+
});
|
|
20112
|
+
this.setToken(response.jwt);
|
|
20113
|
+
return response.user;
|
|
20114
|
+
}
|
|
20099
20115
|
async getLocales(params) {
|
|
20100
20116
|
return await this.baseFetch('i18n/locales', _.merge({
|
|
20101
20117
|
headers: {
|
|
@@ -20712,6 +20728,10 @@ async function generateStrapiTypes(strapi) {
|
|
|
20712
20728
|
'import {BlocksContent} from "@strapi/blocks-react-renderer";',
|
|
20713
20729
|
'',
|
|
20714
20730
|
'export default class Strapi extends StrapiBase {',
|
|
20731
|
+
` public async login(identifier: string, password: string) {`,
|
|
20732
|
+
` return await this.baseLogin<User>(identifier, password);`,
|
|
20733
|
+
' }',
|
|
20734
|
+
'',
|
|
20715
20735
|
methods.join('\n\n'),
|
|
20716
20736
|
'}',
|
|
20717
20737
|
'',
|