griddo-sdk 1.1.4 → 1.2.2
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/.github/workflows/qodana_code_quality.yml +28 -0
- package/.github/workflows/release.yml +47 -0
- package/README.md +1 -1
- package/api/index.js +1 -1
- package/index.js +209 -168
- package/models/structuredData.js +84 -35
- package/package.json +6 -2
- package/qodana.yaml +20 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Qodana
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
pull_request:
|
|
5
|
+
types: [opened]
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
jobs:
|
|
9
|
+
qodana:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
pull-requests: write
|
|
14
|
+
checks: write
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
with:
|
|
18
|
+
fetch-depth: 0
|
|
19
|
+
- name: Set up Node.js
|
|
20
|
+
uses: actions/setup-node@v3
|
|
21
|
+
with:
|
|
22
|
+
node-version: '18'
|
|
23
|
+
- name: Install Eslint
|
|
24
|
+
run: npm install eslint --ignore-scripts
|
|
25
|
+
- name: 'Qodana Scan'
|
|
26
|
+
uses: JetBrains/qodana-action@latest
|
|
27
|
+
env:
|
|
28
|
+
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
permissions:
|
|
4
|
+
contents: write
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
push:
|
|
9
|
+
tags:
|
|
10
|
+
- 'v*'
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
release:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
id-token: write
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
with:
|
|
21
|
+
fetch-depth: 0
|
|
22
|
+
|
|
23
|
+
- name: Fetch branches
|
|
24
|
+
run: git fetch --all
|
|
25
|
+
|
|
26
|
+
- name: Configure Git
|
|
27
|
+
run: |
|
|
28
|
+
git config user.email "actions@github.com"
|
|
29
|
+
git config user.name "GitHub Actions"
|
|
30
|
+
|
|
31
|
+
- name: Create Change Log
|
|
32
|
+
run: npx changelogithub
|
|
33
|
+
env:
|
|
34
|
+
GITHUB_TOKEN: ${{secrets.GRIDDO_RELEASE_ACCESS_TOKEN}}
|
|
35
|
+
|
|
36
|
+
- name: Install dependencies
|
|
37
|
+
run: npm install
|
|
38
|
+
|
|
39
|
+
- name: Publish package
|
|
40
|
+
uses: actions/setup-node@v4
|
|
41
|
+
with:
|
|
42
|
+
node-version: '20.x'
|
|
43
|
+
registry-url: 'https://registry.npmjs.org'
|
|
44
|
+
- run: npm ci
|
|
45
|
+
- run: npm publish --access public
|
|
46
|
+
env:
|
|
47
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ npm i griddo-sdk
|
|
|
8
8
|
|
|
9
9
|
**USE IT!**
|
|
10
10
|
|
|
11
|
-
Documentation: https://www.notion.so/
|
|
11
|
+
Documentation: https://www.notion.so/griddoio/Griddo-SDK-e2b40859ca5f49b8ad890b1fd5a05ebc
|
|
12
12
|
|
|
13
13
|
For sporadic and reusable works, please consider using the SDK through Griddo Debugger (https://github.com/griddo/griddo-debugger).
|
|
14
14
|
|
package/api/index.js
CHANGED
|
@@ -15,7 +15,7 @@ const publicApi = (env, method, endpoint, body = null, headers = {}) => {
|
|
|
15
15
|
token,
|
|
16
16
|
} = env;
|
|
17
17
|
if (!publicApi) throw new Error('Public API should be declared at initialization.');
|
|
18
|
-
return apiCall(
|
|
18
|
+
return apiCall(publicApi, token, method, endpoint, body, headers);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
const apiCall = (api, token, method, endpoint, body = null, headers = {}) => {
|
package/index.js
CHANGED
|
@@ -1,173 +1,214 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const {
|
|
3
|
-
const {
|
|
4
|
-
const {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const {api} = require('./api');
|
|
2
|
+
const {getToken} = require('./models/auth');
|
|
3
|
+
const {getPages, getPage, savePage, deletePage, restorePage} = require('./models/pages');
|
|
4
|
+
const {
|
|
5
|
+
getStructuredData,
|
|
6
|
+
getStructuredDataByID,
|
|
7
|
+
saveStructuredData,
|
|
8
|
+
deleteStructuredData
|
|
9
|
+
} = require('./models/structuredData');
|
|
10
|
+
const {getLanguages} = require('./models/languages');
|
|
11
|
+
const {getStatus} = require('./models/liveStatus');
|
|
12
|
+
const {sendAlert} = require('./models/alerts');
|
|
8
13
|
|
|
9
14
|
class SDK {
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
15
|
+
constructor() {
|
|
16
|
+
this._env = {};
|
|
17
|
+
this.connect = this.connect.bind(this);
|
|
18
|
+
this.api = this.api.bind(this);
|
|
19
|
+
this.getPage = this.getPage.bind(this);
|
|
20
|
+
this.savePage = this.savePage.bind(this);
|
|
21
|
+
this.deletePage = this.deletePage.bind(this);
|
|
22
|
+
this.restorePage = this.restorePage.bind(this);
|
|
23
|
+
this.mapPages = this.mapPages.bind(this);
|
|
24
|
+
this.mapModulesFromPage = this.mapModulesFromPage.bind(this);
|
|
25
|
+
this.mapModules = this.mapModules.bind(this);
|
|
26
|
+
this.getStructuredDataByID = this.getStructuredDataByID.bind(this);
|
|
27
|
+
this.getStructuredData = this.getStructuredData.bind(this);
|
|
28
|
+
this.getPaginationStructuredData = this.getPaginationStructuredData.bind(this);
|
|
29
|
+
this.saveStructuredData = this.saveStructuredData.bind(this);
|
|
30
|
+
this.deleteStructuredData = this.deleteStructuredData.bind(this);
|
|
31
|
+
this.mapStructuredData = this.mapStructuredData.bind(this);
|
|
32
|
+
this.getLanguage = this.getLanguage.bind(this);
|
|
33
|
+
this.getDefaultLanguage = this.getDefaultLanguage.bind(this);
|
|
34
|
+
this.sendAlert = this.sendAlert.bind(this);
|
|
35
|
+
this.languages = [];
|
|
36
|
+
this.liveStatus = {};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async connect(environment) {
|
|
40
|
+
const {
|
|
41
|
+
api,
|
|
42
|
+
publicApi,
|
|
43
|
+
user,
|
|
44
|
+
password,
|
|
45
|
+
verbose,
|
|
46
|
+
} = environment;
|
|
47
|
+
if (!api || !user || !password) throw new Error('Connection object must contain the keys api, user and password.');
|
|
48
|
+
if (!publicApi) console.log('WARNING: Connection object should contain the key publicApi (!!!).\n\n');
|
|
49
|
+
this._env = {
|
|
50
|
+
api: api.endsWith('/') ? api.slice(0, -1) : api,
|
|
51
|
+
publicApi: publicApi && (publicApi.endsWith('/') ? publicApi.slice(0, -1) : publicApi),
|
|
52
|
+
token: await getToken(environment),
|
|
53
|
+
verbose,
|
|
54
|
+
};
|
|
55
|
+
this.languages = await getLanguages(this._env);
|
|
56
|
+
|
|
57
|
+
const liveStatus = await getStatus(this._env);
|
|
58
|
+
for (const item of liveStatus) this.liveStatus[item.status] = item.id;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
getLanguage(key, value) {
|
|
62
|
+
return this.languages.find(item => item[key] === value);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
getDefaultLanguage() {
|
|
66
|
+
return this.languages.find(item => item.isDefault);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
async mapPages(callback, templateName) {
|
|
70
|
+
if (this._env.verbose) console.log(`\nMapping ${templateName || 'all'} pages with callback function ${callback.name}...`);
|
|
71
|
+
if (!callback || typeof (callback) !== 'function') throw new Error('Cannot map pages without a callback function.');
|
|
72
|
+
const pages = await getPages(this._env, templateName);
|
|
73
|
+
if (!pages?.length) {
|
|
74
|
+
if (this._env.verbose) console.log('- No pages found.');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
for (const pageId of pages) {
|
|
78
|
+
if (this._env.verbose) console.log('- Mapping page', pageId);
|
|
79
|
+
const page = await getPage(this._env, pageId)
|
|
80
|
+
const pageProtected = JSON.parse(JSON.stringify(page));
|
|
81
|
+
const result = await callback(pageProtected);
|
|
82
|
+
if (result && JSON.stringify(page) !== JSON.stringify(result)) {
|
|
83
|
+
await savePage(this._env, result)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
async mapModulesFromPage(page, moduleName, callback) {
|
|
89
|
+
if (this._env.verbose) console.log(`\tMapping modules ${moduleName} with callback function ${callback.name}...`);
|
|
90
|
+
if (!callback || typeof (callback) !== 'function') throw new Error('Cannot map modules without a callback function.');
|
|
91
|
+
if (!moduleName) throw new Error('Cannot map modules in page without selecting the module to map.');
|
|
92
|
+
if (!page || typeof (page) !== 'object') throw new Error('Page to map modules not found.');
|
|
93
|
+
const protectedPage = JSON.parse(JSON.stringify(page));
|
|
94
|
+
let found = false;
|
|
95
|
+
const search = async (modulePiece) => {
|
|
96
|
+
for (const key of Object.keys(modulePiece)) {
|
|
97
|
+
const module = modulePiece[key];
|
|
98
|
+
if (!module || typeof (module) !== 'object') continue;
|
|
99
|
+
if (module.component === moduleName) {
|
|
100
|
+
if (!found && this._env.verbose) console.log(`\tModule ${moduleName} found.`);
|
|
101
|
+
const newModule = await callback(JSON.parse(JSON.stringify(module)));
|
|
102
|
+
if (newModule) modulePiece[key] = newModule;
|
|
103
|
+
found = true;
|
|
104
|
+
}
|
|
105
|
+
await search(module);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
await search(protectedPage);
|
|
109
|
+
if (!found && this._env.verbose) console.log(`\tModule ${moduleName} not found.`);
|
|
110
|
+
return protectedPage;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
async mapModules(callback, moduleName, template) {
|
|
114
|
+
if (this._env.verbose) console.log(`\nMapping modules ${moduleName} from ${template || 'all'} pages with callback function ${callback.name}...`);
|
|
115
|
+
if (!callback || typeof (callback) !== 'function') throw new Error('Cannot map modules without a callback function.');
|
|
116
|
+
if (!moduleName) throw new Error('Cannot map modules in page without selecting the module to map.');
|
|
117
|
+
const fixPage = (page) => this.mapModulesFromPage(page, moduleName, callback);
|
|
118
|
+
await this.mapPages(fixPage, template);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
async savePage(page) {
|
|
122
|
+
return await savePage(this._env, page);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
async getPage(id) {
|
|
126
|
+
return await getPage(this._env, id);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
async deletePage(id) {
|
|
130
|
+
return await deletePage(this._env, id);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
async restorePage(id) {
|
|
134
|
+
return await restorePage(this._env, id);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
async getStructuredDataByID(id) {
|
|
138
|
+
return await getStructuredDataByID(this._env, id);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async getStructuredData(
|
|
142
|
+
contentType,
|
|
143
|
+
site = null,
|
|
144
|
+
language = null,
|
|
145
|
+
queryParams = {
|
|
146
|
+
page: 0,
|
|
147
|
+
itemsPerPage: 0,
|
|
148
|
+
pagination: false,
|
|
149
|
+
deleted: false,
|
|
150
|
+
includeDraft: true,
|
|
151
|
+
relatedFields: false,
|
|
152
|
+
query: null,
|
|
153
|
+
},
|
|
154
|
+
) {
|
|
155
|
+
return await getStructuredData(this._env, contentType, site, language, queryParams);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async getPaginationStructuredData(
|
|
159
|
+
contentType,
|
|
160
|
+
site = null,
|
|
161
|
+
language = null,
|
|
162
|
+
queryParams = {
|
|
163
|
+
page: 1,
|
|
164
|
+
itemsPerPage: 50,
|
|
165
|
+
pagination: true,
|
|
166
|
+
deleted: false,
|
|
167
|
+
includeDraft: false,
|
|
168
|
+
relatedFields: false,
|
|
169
|
+
query: null,
|
|
170
|
+
},
|
|
171
|
+
) {
|
|
172
|
+
return await getStructuredData(this._env, contentType, site, language, queryParams);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async saveStructuredData(structuredData) {
|
|
176
|
+
return await saveStructuredData(this._env, structuredData);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
async deleteStructuredData(id) {
|
|
180
|
+
return await deleteStructuredData(this._env, id);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
async mapStructuredData(callback, contentType) {
|
|
184
|
+
if (this._env.verbose) console.log(`\nMapping ${contentType || 'all'} structured data with callback function ${callback.name}...`);
|
|
185
|
+
if (!callback || typeof (callback) !== 'function') throw new Error('Cannot map structured data without a callback function.');
|
|
186
|
+
const content = await getStructuredData(this._env, contentType);
|
|
187
|
+
if (!content?.length) {
|
|
188
|
+
if (this._env.verbose) console.log('- No structured data found.');
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
for (const structuredData of content) {
|
|
192
|
+
if (this._env.verbose) console.log('- Mapping structured data', structuredData.id);
|
|
193
|
+
const dataProtected = JSON.parse(JSON.stringify(structuredData));
|
|
194
|
+
const result = await callback(dataProtected);
|
|
195
|
+
if (result && JSON.stringify(structuredData) !== JSON.stringify(result)) {
|
|
196
|
+
await saveStructuredData(this._env, result)
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
async api(...params) {
|
|
202
|
+
return await api(this._env, ...params);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
showLog(...text) {
|
|
206
|
+
console.log(`\t${text.join(' ')} `);
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
async sendAlert(alert) {
|
|
210
|
+
return await sendAlert(this._env, alert);
|
|
211
|
+
};
|
|
171
212
|
};
|
|
172
213
|
|
|
173
214
|
module.exports = SDK;
|
package/models/structuredData.js
CHANGED
|
@@ -1,45 +1,94 @@
|
|
|
1
|
-
const {
|
|
2
|
-
|
|
3
|
-
const getStructuredData = async (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
const {api} = require('../api');
|
|
2
|
+
|
|
3
|
+
const getStructuredData = async (
|
|
4
|
+
env,
|
|
5
|
+
contentType,
|
|
6
|
+
site = null,
|
|
7
|
+
language = null,
|
|
8
|
+
queryParams = {
|
|
9
|
+
page: 0,
|
|
10
|
+
itemsPerPage: 0,
|
|
11
|
+
pagination: false,
|
|
12
|
+
deleted: false,
|
|
13
|
+
includeDraft: true,
|
|
14
|
+
relatedFields: false,
|
|
15
|
+
query: null,
|
|
16
|
+
},
|
|
17
|
+
) => {
|
|
18
|
+
const headers = {
|
|
19
|
+
lang: language,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
if (!queryParams.pagination) {
|
|
23
|
+
delete queryParams.page
|
|
24
|
+
delete queryParams.itemsPerPage
|
|
25
|
+
delete queryParams.deleted
|
|
26
|
+
delete queryParams.relatedFields
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!queryParams.query) {
|
|
30
|
+
delete queryParams.query
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const query = new URLSearchParams(queryParams).toString();
|
|
34
|
+
const path = `${site ? `/site/${site}` : ''}/structured_data_contents/${contentType || ''}?${query}`
|
|
35
|
+
|
|
36
|
+
const items = await api(env, 'get', path, null, headers)
|
|
37
|
+
.then(data => queryParams.pagination ? data : data.items);
|
|
38
|
+
if (env.verbose) {
|
|
39
|
+
console.log(`\tStructured data ${contentType} loaded.`);
|
|
40
|
+
}
|
|
41
|
+
return items;
|
|
11
42
|
};
|
|
12
43
|
|
|
44
|
+
const getStructuredDataByID = async (
|
|
45
|
+
env,
|
|
46
|
+
id
|
|
47
|
+
) => {
|
|
48
|
+
const headers = {};
|
|
49
|
+
const path = `/structured_data_content/${id}`
|
|
50
|
+
|
|
51
|
+
const items = await api(env, 'get', path, null, headers)
|
|
52
|
+
.then(data => data);
|
|
53
|
+
|
|
54
|
+
if (env.verbose) {
|
|
55
|
+
console.log(`\tStructured data by content ID: ${id} loaded.`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return items;
|
|
59
|
+
}
|
|
60
|
+
|
|
13
61
|
const saveStructuredData = async (env, structuredData) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
62
|
+
const actions = {
|
|
63
|
+
new: {
|
|
64
|
+
method: 'post',
|
|
65
|
+
endpoint: '/structured_data_content/',
|
|
66
|
+
actionName: 'created',
|
|
67
|
+
},
|
|
68
|
+
update: {
|
|
69
|
+
method: 'put',
|
|
70
|
+
endpoint: `/structured_data_content/${structuredData.id}`,
|
|
71
|
+
actionName: 'updated',
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
const {
|
|
75
|
+
method,
|
|
76
|
+
endpoint,
|
|
77
|
+
actionName,
|
|
78
|
+
} = actions[structuredData.id ? 'update' : 'new'];
|
|
79
|
+
const savedItem = await api(env, method, endpoint, structuredData);
|
|
80
|
+
if (env.verbose) console.log(`\tStructured data ${structuredData?.content?.title || structuredData?.content?.label || 'untitled'} in ${structuredData.structuredData} ${actionName}.`);
|
|
81
|
+
return savedItem;
|
|
34
82
|
};
|
|
35
83
|
|
|
36
84
|
const deleteStructuredData = (env, id) => {
|
|
37
|
-
|
|
38
|
-
|
|
85
|
+
if (env.verbose) console.log('\tDelete structured data', id);
|
|
86
|
+
return api(env, 'delete', `/structured_data_content/${id}`);
|
|
39
87
|
};
|
|
40
88
|
|
|
41
89
|
module.exports = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
90
|
+
getStructuredData,
|
|
91
|
+
getStructuredDataByID,
|
|
92
|
+
saveStructuredData,
|
|
93
|
+
deleteStructuredData,
|
|
45
94
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "griddo-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"release": "bumpp --commit --push --tag"
|
|
8
9
|
},
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
@@ -18,5 +19,8 @@
|
|
|
18
19
|
"homepage": "https://github.com/griddo/griddo-sdk#readme",
|
|
19
20
|
"dependencies": {
|
|
20
21
|
"axios": "0.26.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"bumpp": "^9.4.1"
|
|
21
25
|
}
|
|
22
26
|
}
|
package/qodana.yaml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------------#
|
|
2
|
+
# Qodana analysis is configured by qodana.yaml file #
|
|
3
|
+
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
|
|
4
|
+
#-------------------------------------------------------------------------------#
|
|
5
|
+
version: "1.0"
|
|
6
|
+
#Specify inspection profile for code analysis
|
|
7
|
+
profile:
|
|
8
|
+
name: qodana.starter
|
|
9
|
+
include:
|
|
10
|
+
- name: CheckDependencyLicenses
|
|
11
|
+
- name: Eslint
|
|
12
|
+
linter: jetbrains/qodana-js:latest
|
|
13
|
+
exclude:
|
|
14
|
+
- name: JSXDomNesting
|
|
15
|
+
- name: VueDataFunction
|
|
16
|
+
- name: VueDeprecatedSymbol
|
|
17
|
+
- name: VueDuplicateTag
|
|
18
|
+
- name: VueMissingComponentImportInspection
|
|
19
|
+
- name: VueUnrecognizedDirective
|
|
20
|
+
- name: VueUnrecognizedSlot
|