@malevich-studio/strapi-sdk-typescript 1.2.1 → 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 +32 -0
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +32 -0
- package/dist/cli.mjs.map +1 -1
- package/dist/generator/attributes/time.d.ts +11 -0
- package/dist/index.cjs +16 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -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: {
|
|
@@ -20531,6 +20547,17 @@ class Dynamiczone extends BaseRelation {
|
|
|
20531
20547
|
}
|
|
20532
20548
|
}
|
|
20533
20549
|
|
|
20550
|
+
class Time extends Base {
|
|
20551
|
+
constructor(name, attribute) {
|
|
20552
|
+
super(name, attribute);
|
|
20553
|
+
this.name = name;
|
|
20554
|
+
this.attribute = attribute;
|
|
20555
|
+
}
|
|
20556
|
+
getType() {
|
|
20557
|
+
return 'string';
|
|
20558
|
+
}
|
|
20559
|
+
}
|
|
20560
|
+
|
|
20534
20561
|
const types = {
|
|
20535
20562
|
'string': String$1,
|
|
20536
20563
|
'text': String$1,
|
|
@@ -20546,6 +20573,7 @@ const types = {
|
|
|
20546
20573
|
'enumeration': Enumeration,
|
|
20547
20574
|
'date': Date$1,
|
|
20548
20575
|
'datetime': DateTime,
|
|
20576
|
+
'time': Time,
|
|
20549
20577
|
'component': Component,
|
|
20550
20578
|
'dynamiczone': Dynamiczone,
|
|
20551
20579
|
'blocks': Blocks,
|
|
@@ -20720,6 +20748,10 @@ async function generateStrapiTypes(strapi) {
|
|
|
20720
20748
|
'import {BlocksContent} from "@strapi/blocks-react-renderer";',
|
|
20721
20749
|
'',
|
|
20722
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
|
+
'',
|
|
20723
20755
|
methods.join('\n\n'),
|
|
20724
20756
|
'}',
|
|
20725
20757
|
'',
|