@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.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: {
|
|
@@ -20511,6 +20527,17 @@ class Dynamiczone extends BaseRelation {
|
|
|
20511
20527
|
}
|
|
20512
20528
|
}
|
|
20513
20529
|
|
|
20530
|
+
class Time extends Base {
|
|
20531
|
+
constructor(name, attribute) {
|
|
20532
|
+
super(name, attribute);
|
|
20533
|
+
this.name = name;
|
|
20534
|
+
this.attribute = attribute;
|
|
20535
|
+
}
|
|
20536
|
+
getType() {
|
|
20537
|
+
return 'string';
|
|
20538
|
+
}
|
|
20539
|
+
}
|
|
20540
|
+
|
|
20514
20541
|
const types = {
|
|
20515
20542
|
'string': String$1,
|
|
20516
20543
|
'text': String$1,
|
|
@@ -20526,6 +20553,7 @@ const types = {
|
|
|
20526
20553
|
'enumeration': Enumeration,
|
|
20527
20554
|
'date': Date$1,
|
|
20528
20555
|
'datetime': DateTime,
|
|
20556
|
+
'time': Time,
|
|
20529
20557
|
'component': Component,
|
|
20530
20558
|
'dynamiczone': Dynamiczone,
|
|
20531
20559
|
'blocks': Blocks,
|
|
@@ -20700,6 +20728,10 @@ async function generateStrapiTypes(strapi) {
|
|
|
20700
20728
|
'import {BlocksContent} from "@strapi/blocks-react-renderer";',
|
|
20701
20729
|
'',
|
|
20702
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
|
+
'',
|
|
20703
20735
|
methods.join('\n\n'),
|
|
20704
20736
|
'}',
|
|
20705
20737
|
'',
|