@cocreate/api 1.21.3 → 1.22.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [1.22.0](https://github.com/CoCreate-app/CoCreate-api/compare/v1.21.3...v1.22.0) (2024-11-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * handling array[] ([93bafda](https://github.com/CoCreate-app/CoCreate-api/commit/93bafdaab1712ae1c99a408142c8ec9e912a34c5))
7
+ * observer taget has been renamed to selector ([9802a6c](https://github.com/CoCreate-app/CoCreate-api/commit/9802a6c96b0f37de1166f240720544652eb5666b))
8
+ * pretier.config.js and file formating ([12031c1](https://github.com/CoCreate-app/CoCreate-api/commit/12031c1ea0db05ae7881fdca959ec022ee2cae86))
9
+
10
+
11
+ ### Features
12
+
13
+ * add prettier.config.js and format files ([090db4f](https://github.com/CoCreate-app/CoCreate-api/commit/090db4f1d7c2e26d0b76b82ab70b83c58be49323))
14
+
1
15
  ## [1.21.3](https://github.com/CoCreate-app/CoCreate-api/compare/v1.21.2...v1.21.3) (2024-08-24)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/api",
3
- "version": "1.21.3",
3
+ "version": "1.22.0",
4
4
  "description": "A simple api helper component in vanilla javascript used by JavaScript developers to create thirdparty api intergrations. CoCreate-api includes the client component and server side for api processing. Thirdparty apis can be accessible using HTML5 attributes and/or JavaScript API. ",
5
5
  "keywords": [
6
6
  "thirdparty-api-intergration",
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ tabWidth: 4,
3
+ semi: true,
4
+ trailingComma: "none",
5
+ bracketSameLine: true,
6
+ useTabs: true,
7
+ overrides: [
8
+ {
9
+ files: ["*.json", "*.yml", "*.yaml"],
10
+ options: {
11
+ tabWidth: 2,
12
+ useTabs: false
13
+ },
14
+ }
15
+ ],
16
+ };
package/src/index.js CHANGED
@@ -54,7 +54,7 @@ const CoCreateApi = {
54
54
  Observer.init({
55
55
  name: `${name}NodeObserver`,
56
56
  observe: ['addedNodes'],
57
- target: `[${name}]`,
57
+ selector: `[${name}]`,
58
58
  callback: function (mutation) {
59
59
  inputEvent(mutation.target)
60
60
  self.request({ name, element: mutation.target, type: 'nodeObserver' })
@@ -139,7 +139,18 @@ const CoCreateApi = {
139
139
  continue
140
140
  let key = elements[i].getAttribute(`${name}-key`)
141
141
  if (key) {
142
- data[key] = await elements[i].getValue()
142
+ let value = await elements[i].getValue()
143
+ if (key.endsWith('[]')) {
144
+ if (!data[key])
145
+ data[key] = [];
146
+
147
+ if (Array.isArray(value))
148
+ data[key].push(...value);
149
+ else
150
+ data[key].push(value);
151
+ } else
152
+ data[key] = await elements[i].getValue()
153
+
143
154
  }
144
155
 
145
156
  let endpoint = elements[i].getAttribute('endpoint')
@@ -211,7 +222,7 @@ const CoCreateApi = {
211
222
  Observer.init({
212
223
  name: `apiNodeObserver`,
213
224
  observe: ['addedNodes'],
214
- target: '[module], [api]',
225
+ selector: '[module], [api]',
215
226
  callback: function (mutation) {
216
227
  let name = mutation.target.getAttribute('api') || mutation.target.getAttribute('module')
217
228
  CoCreateApi.register({ name, endPoints: {} });