@cocreate/api 1.20.5 → 1.20.6

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,10 @@
1
+ ## [1.20.6](https://github.com/CoCreate-app/CoCreate-api/compare/v1.20.5...v1.20.6) (2024-04-29)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * bump cocreate dependencies ([28dabef](https://github.com/CoCreate-app/CoCreate-api/commit/28dabefd52299a59fc7cbe1fe6fbe1d15c074479))
7
+
1
8
  ## [1.20.5](https://github.com/CoCreate-app/CoCreate-api/compare/v1.20.4...v1.20.5) (2024-04-27)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/api",
3
- "version": "1.20.5",
3
+ "version": "1.20.6",
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",
@@ -59,11 +59,11 @@
59
59
  "webpack-log": "^3.0.1"
60
60
  },
61
61
  "dependencies": {
62
- "@cocreate/actions": "^1.15.1",
63
- "@cocreate/crud-client": "^1.32.2",
64
- "@cocreate/element-prototype": "^1.15.0",
65
- "@cocreate/render": "^1.37.1",
66
- "@cocreate/socket-client": "^1.36.1",
67
- "@cocreate/utils": "^1.30.0"
62
+ "@cocreate/actions": "^1.18.1",
63
+ "@cocreate/crud-client": "^1.33.8",
64
+ "@cocreate/element-prototype": "^1.22.2",
65
+ "@cocreate/render": "^1.40.3",
66
+ "@cocreate/socket-client": "^1.39.0",
67
+ "@cocreate/utils": "^1.33.6"
68
68
  }
69
69
  }
package/src/index.js CHANGED
@@ -124,7 +124,36 @@ const CoCreateApi = {
124
124
  Socket.send({ method: name + '.' + method, [name]: data, broadcast: false, broadcastBrowser: false, status: 'await' });
125
125
  },
126
126
 
127
- // TODO: handle $param operator
127
+ /**
128
+ * TODO: Implement Enhanced API Configuration Handling
129
+ *
130
+ * Description:
131
+ * - Implement functionality to dynamically handle API configurations, supporting both complete and base URL endpoints with automatic method-based path appending.
132
+ * - Enable dynamic generation of query parameters from a designated object (`stripe` in the examples) when `query` is true.
133
+ *
134
+ * Requirements:
135
+ * 1. Dynamic Endpoint Handling:
136
+ * - Check if the endpoint configuration is a complete URL or a base URL.
137
+ * - If the `method` derived path is not already included in the endpoint, append it dynamically.
138
+ * Example:
139
+ * `{ "method": "stripe.accounts.retrieve", "endpoint": "https://api.stripe.com", "query": true, "stripe": { "acct": "acct_123", "name": "John Doe" } }`
140
+ * `{ "method": "stripe.accounts.retrieve", "endpoint": "https://api.stripe.com/accounts/retrieve", "query": true, "stripe": { "acct": "acct_123", "name": "John Doe" } }`
141
+ * - Develop logic to parse the `method` and check against the endpoint. If necessary, append the appropriate API method segment.
142
+ *
143
+ * 2. Query Parameter Handling:
144
+ * - Dynamically construct and append query parameters from the `stripe` object if `query` is true. Ensure proper URL-encoding of keys and values.
145
+ *
146
+ * 3. Security:
147
+ * - Use the `method` for permission checks, ensuring that each API request complies with security protocols.
148
+ *
149
+ * 4. Testing:
150
+ * - Test both scenarios where the endpoint may or may not include the method path to ensure the dynamic construction works correctly.
151
+ * - Ensure that all query parameters are correctly formatted and appended.
152
+ *
153
+ * Notes:
154
+ * - Consider utility functions for parsing and modifying URLs, as well as for encoding parameters.
155
+ * - Maintain clear and detailed documentation for each part of the implementation to assist future development and troubleshooting.
156
+ */
128
157
  getData: async function ({ name, method, element, form }) {
129
158
  let data = {}
130
159
 
@@ -163,7 +192,6 @@ const CoCreateApi = {
163
192
  return data
164
193
  },
165
194
 
166
- // TODO: handle $param operator
167
195
  setData: function ({ name, method, data, form }) {
168
196
  if (!form)
169
197
  form = document;