@appconda/nextjs 1.0.17 → 1.0.19

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.
Files changed (236) hide show
  1. package/dist/Cache/Adapter.js +1 -0
  2. package/dist/Cache/Adapters/Filesystem.js +102 -0
  3. package/dist/Cache/Adapters/Memory.js +46 -0
  4. package/dist/Cache/Adapters/None.js +27 -0
  5. package/dist/Cache/Adapters/Redis.js +79 -0
  6. package/dist/Cache/Adapters/Sharding.js +72 -0
  7. package/dist/Cache/Cache.js +51 -0
  8. package/dist/Cache/index.js +5 -0
  9. package/dist/Cache/test.js +0 -0
  10. package/dist/Services.js +28 -0
  11. package/dist/actions/actionClient.js +35 -0
  12. package/dist/actions/index.js +1 -0
  13. package/dist/actions/nodes.js +9 -0
  14. package/dist/client.js +334 -0
  15. package/dist/decorators/Cache.js +78 -0
  16. package/dist/decorators/CacheKey.js +8 -0
  17. package/dist/decorators/Invalidate.js +46 -0
  18. package/dist/enums/api-service.js +14 -0
  19. package/dist/enums/api.js +6 -0
  20. package/dist/enums/auth-method.js +10 -0
  21. package/dist/enums/authentication-factor.js +7 -0
  22. package/dist/enums/authenticator-type.js +4 -0
  23. package/dist/enums/browser.js +17 -0
  24. package/dist/enums/compression.js +6 -0
  25. package/dist/enums/credit-card.js +19 -0
  26. package/dist/enums/database-usage-range.js +6 -0
  27. package/dist/enums/email-template-locale.js +134 -0
  28. package/dist/enums/email-template-type.js +10 -0
  29. package/dist/enums/entities/EntityLimitType.js +5 -0
  30. package/dist/enums/entities/PropertyAttributeName.js +28 -0
  31. package/dist/enums/entities/PropertyCondition.js +9 -0
  32. package/dist/enums/entities/PropertyType.js +17 -0
  33. package/dist/enums/entities/PropertyValueType.js +7 -0
  34. package/dist/enums/entities/RowAccess.js +1 -0
  35. package/dist/enums/entities/ViewFilterCondition.js +13 -0
  36. package/dist/enums/execution-method.js +9 -0
  37. package/dist/enums/flag.js +198 -0
  38. package/dist/enums/function-usage-range.js +6 -0
  39. package/dist/enums/image-format.js +8 -0
  40. package/dist/enums/image-gravity.js +12 -0
  41. package/dist/enums/index-type.js +6 -0
  42. package/dist/enums/messaging-provider-type.js +6 -0
  43. package/dist/enums/name.js +15 -0
  44. package/dist/enums/o-auth-provider copy.js +42 -0
  45. package/dist/enums/o-auth-provider.js +42 -0
  46. package/dist/enums/password-hash.js +14 -0
  47. package/dist/enums/platform-type.js +18 -0
  48. package/dist/enums/project-usage-range.js +5 -0
  49. package/dist/enums/region.js +5 -0
  50. package/dist/enums/relation-mutate.js +6 -0
  51. package/dist/enums/relationship-type.js +7 -0
  52. package/dist/enums/resource-type.js +5 -0
  53. package/dist/enums/runtime.js +49 -0
  54. package/dist/enums/s-m-t-p-secure.js +4 -0
  55. package/dist/enums/shared/ApplicationLayout.js +5 -0
  56. package/dist/enums/shared/Colors.js +25 -0
  57. package/dist/enums/shared/InputType.js +7 -0
  58. package/dist/enums/shared/Periodicity.js +8 -0
  59. package/dist/enums/shared/SvgIcon.js +38 -0
  60. package/dist/enums/shared/Theme.js +5 -0
  61. package/dist/enums/sms-template-locale.js +134 -0
  62. package/dist/enums/sms-template-type.js +7 -0
  63. package/dist/enums/smtp-encryption.js +6 -0
  64. package/dist/enums/storage-usage-range.js +6 -0
  65. package/dist/enums/subscriptions/PricingModel.js +11 -0
  66. package/dist/enums/subscriptions/SubscriptionBillingPeriod.js +10 -0
  67. package/dist/enums/subscriptions/SubscriptionFeatureLimitType.js +12 -0
  68. package/dist/enums/subscriptions/SubscriptionPriceType.js +7 -0
  69. package/dist/enums/tenants/LinkedAccountStatus.js +6 -0
  70. package/dist/enums/tenants/TenantUserJoined.js +7 -0
  71. package/dist/enums/tenants/TenantUserStatus.js +7 -0
  72. package/dist/enums/tenants/TenantUserType.js +6 -0
  73. package/dist/enums/user-usage-range.js +6 -0
  74. package/dist/getAppcondaClient.js +42 -0
  75. package/dist/getSDKForCurrentUser.js +62 -0
  76. package/dist/id.js +44 -0
  77. package/dist/iife/sdk.js +7063 -7805
  78. package/dist/index.js +12558 -0
  79. package/dist/index.js.map +1 -0
  80. package/dist/inputFile.js +16 -0
  81. package/dist/lib/Registry/Registry.js +55 -0
  82. package/dist/lib/Registry/index.js +1 -0
  83. package/dist/models.js +1 -0
  84. package/dist/permission.js +53 -0
  85. package/dist/query.js +203 -0
  86. package/dist/role.js +93 -0
  87. package/dist/service-client.js +13 -0
  88. package/dist/service.js +22 -0
  89. package/dist/services/account.js +1259 -0
  90. package/dist/services/applets.js +39 -0
  91. package/dist/services/avatars.js +250 -0
  92. package/dist/services/community.js +68 -0
  93. package/dist/services/configuration.js +10 -0
  94. package/dist/services/databases.js +1735 -0
  95. package/dist/services/functions.js +809 -0
  96. package/dist/services/graphql.js +56 -0
  97. package/dist/services/health.js +462 -0
  98. package/dist/services/locale.js +143 -0
  99. package/dist/services/messaging.js +1919 -0
  100. package/dist/services/node.js +10 -0
  101. package/dist/services/permissions.js +89 -0
  102. package/dist/services/pricing.js +20 -0
  103. package/dist/services/projects.js +1525 -0
  104. package/dist/services/roles.js +71 -0
  105. package/dist/services/schema.js +47 -0
  106. package/dist/services/storage.js +473 -0
  107. package/dist/services/subscription.js +45 -0
  108. package/dist/services/teams.js +394 -0
  109. package/dist/services/tenant-subscription.js +51 -0
  110. package/dist/services/tenant.js +124 -0
  111. package/dist/services/users.js +1282 -0
  112. package/dist/services/waitlist.js +11 -0
  113. package/package.json +5 -12
  114. package/tsconfig.json +2 -1
  115. package/types/Cache/Adapter.d.ts +10 -0
  116. package/types/Cache/Adapters/Filesystem.d.ts +16 -0
  117. package/types/Cache/Adapters/Memory.d.ts +18 -0
  118. package/types/Cache/Adapters/None.d.ts +12 -0
  119. package/types/Cache/Adapters/Redis.d.ts +14 -0
  120. package/types/Cache/Adapters/Sharding.d.ts +17 -0
  121. package/types/Cache/Cache.d.ts +16 -0
  122. package/types/Cache/index.d.ts +5 -0
  123. package/types/Cache/test.d.ts +0 -0
  124. package/types/Services.d.ts +6 -0
  125. package/types/actions/actionClient.d.ts +4 -0
  126. package/types/actions/index.d.ts +1 -0
  127. package/types/actions/nodes.d.ts +4 -0
  128. package/types/client.d.ts +141 -0
  129. package/types/decorators/Cache.d.ts +1 -0
  130. package/types/decorators/CacheKey.d.ts +1 -0
  131. package/types/decorators/Invalidate.d.ts +1 -0
  132. package/types/enums/api-service.d.ts +13 -0
  133. package/types/enums/api.d.ts +5 -0
  134. package/types/enums/auth-method.d.ts +9 -0
  135. package/types/enums/authentication-factor.d.ts +6 -0
  136. package/types/enums/authenticator-type.d.ts +3 -0
  137. package/types/enums/browser.d.ts +16 -0
  138. package/types/enums/compression.d.ts +5 -0
  139. package/types/enums/credit-card.d.ts +18 -0
  140. package/types/enums/database-usage-range.d.ts +5 -0
  141. package/types/enums/email-template-locale.d.ts +133 -0
  142. package/types/enums/email-template-type.d.ts +9 -0
  143. package/types/enums/entities/EntityLimitType.d.ts +4 -0
  144. package/types/enums/entities/PropertyAttributeName.d.ts +27 -0
  145. package/types/enums/entities/PropertyCondition.d.ts +7 -0
  146. package/types/enums/entities/PropertyType.d.ts +12 -0
  147. package/types/enums/entities/PropertyValueType.d.ts +6 -0
  148. package/types/enums/entities/RowAccess.d.ts +2 -0
  149. package/types/enums/entities/ViewFilterCondition.d.ts +12 -0
  150. package/types/enums/execution-method.d.ts +8 -0
  151. package/types/enums/flag.d.ts +197 -0
  152. package/types/enums/function-usage-range.d.ts +5 -0
  153. package/types/enums/image-format.d.ts +7 -0
  154. package/types/enums/image-gravity.d.ts +11 -0
  155. package/types/enums/index-type.d.ts +5 -0
  156. package/types/enums/messaging-provider-type.d.ts +5 -0
  157. package/types/enums/name.d.ts +14 -0
  158. package/types/enums/o-auth-provider copy.d.ts +41 -0
  159. package/types/enums/o-auth-provider.d.ts +41 -0
  160. package/types/enums/password-hash.d.ts +13 -0
  161. package/types/enums/platform-type.d.ts +17 -0
  162. package/types/enums/project-usage-range.d.ts +4 -0
  163. package/types/enums/region.d.ts +4 -0
  164. package/types/enums/relation-mutate.d.ts +5 -0
  165. package/types/enums/relationship-type.d.ts +6 -0
  166. package/types/enums/resource-type.d.ts +4 -0
  167. package/types/enums/runtime.d.ts +48 -0
  168. package/types/enums/s-m-t-p-secure.d.ts +3 -0
  169. package/types/enums/shared/ApplicationLayout.d.ts +4 -0
  170. package/types/enums/shared/Colors.d.ts +24 -0
  171. package/types/enums/shared/InputType.d.ts +6 -0
  172. package/types/enums/shared/Periodicity.d.ts +7 -0
  173. package/types/enums/shared/SvgIcon.d.ts +37 -0
  174. package/types/enums/shared/Theme.d.ts +4 -0
  175. package/types/enums/sms-template-locale.d.ts +133 -0
  176. package/types/enums/sms-template-type.d.ts +6 -0
  177. package/types/enums/smtp-encryption.d.ts +5 -0
  178. package/types/enums/storage-usage-range.d.ts +5 -0
  179. package/types/enums/subscriptions/PricingModel.d.ts +11 -0
  180. package/types/enums/subscriptions/SubscriptionBillingPeriod.d.ts +10 -0
  181. package/types/enums/subscriptions/SubscriptionFeatureLimitType.d.ts +10 -0
  182. package/types/enums/subscriptions/SubscriptionPriceType.d.ts +7 -0
  183. package/types/enums/tenants/LinkedAccountStatus.d.ts +5 -0
  184. package/types/enums/tenants/TenantUserJoined.d.ts +6 -0
  185. package/types/enums/tenants/TenantUserStatus.d.ts +6 -0
  186. package/types/enums/tenants/TenantUserType.d.ts +5 -0
  187. package/types/enums/user-usage-range.d.ts +5 -0
  188. package/types/getAppcondaClient.d.ts +2 -0
  189. package/types/getSDKForCurrentUser.d.ts +33 -0
  190. package/types/id.d.ts +20 -0
  191. package/types/index.d.ts +39 -0
  192. package/types/inputFile.d.ts +6 -0
  193. package/types/lib/Registry/Registry.d.ts +38 -0
  194. package/types/lib/Registry/index.d.ts +1 -0
  195. package/types/models.d.ts +3272 -0
  196. package/types/permission.d.ts +43 -0
  197. package/types/query.d.ts +194 -0
  198. package/types/role.d.ts +70 -0
  199. package/types/service-client.d.ts +7 -0
  200. package/types/service.d.ts +11 -0
  201. package/types/services/account.d.ts +530 -0
  202. package/types/services/acl.d.ts +28 -0
  203. package/types/services/applets.d.ts +9 -0
  204. package/types/services/assistant.d.ts +14 -0
  205. package/types/services/avatars.d.ts +115 -0
  206. package/types/services/community.d.ts +19 -0
  207. package/types/services/configuration.d.ts +5 -0
  208. package/types/services/console.d.ts +15 -0
  209. package/types/services/databases.d.ts +613 -0
  210. package/types/services/functions.d.ts +319 -0
  211. package/types/services/graphql.d.ts +25 -0
  212. package/types/services/health.d.ts +231 -0
  213. package/types/services/locale.d.ts +80 -0
  214. package/types/services/messaging.d.ts +685 -0
  215. package/types/services/migrations.d.ts +185 -0
  216. package/types/services/node.d.ts +5 -0
  217. package/types/services/permissions.d.ts +20 -0
  218. package/types/services/pricing.d.ts +15 -0
  219. package/types/services/project.d.ts +70 -0
  220. package/types/services/projects.d.ts +542 -0
  221. package/types/services/proxy.d.ts +59 -0
  222. package/types/services/roles.d.ts +19 -0
  223. package/types/services/schema.d.ts +17 -0
  224. package/types/services/storage.d.ts +189 -0
  225. package/types/services/subscription-product.d.ts +77 -0
  226. package/types/services/subscription.d.ts +15 -0
  227. package/types/services/teams.d.ts +167 -0
  228. package/types/services/tenant-subscription.d.ts +12 -0
  229. package/types/services/tenant.d.ts +32 -0
  230. package/types/services/users.d.ts +499 -0
  231. package/types/services/vcs.d.ts +108 -0
  232. package/types/services/waitlist.d.ts +5 -0
  233. package/dist/cjs/sdk.js +0 -13300
  234. package/dist/cjs/sdk.js.map +0 -1
  235. package/dist/esm/sdk.js +0 -13278
  236. package/dist/esm/sdk.js.map +0 -1
package/dist/client.js ADDED
@@ -0,0 +1,334 @@
1
+ import { fetch, FormData, File } from 'node-fetch-native-with-agent';
2
+ import { createAgent } from 'node-fetch-native-with-agent/agent';
3
+ class AppcondaException extends Error {
4
+ constructor(message, code = 0, type = '', response = '') {
5
+ super(message);
6
+ this.name = 'AppcondaException';
7
+ this.message = message;
8
+ this.code = code;
9
+ this.type = type;
10
+ this.response = response;
11
+ }
12
+ }
13
+ function getUserAgent() {
14
+ let ua = 'AppcondaNodeJSSDK/14.1.0';
15
+ // `process` is a global in Node.js, but not fully available in all runtimes.
16
+ const platform = [];
17
+ if (typeof process !== 'undefined') {
18
+ if (typeof process.platform === 'string')
19
+ platform.push(process.platform);
20
+ if (typeof process.arch === 'string')
21
+ platform.push(process.arch);
22
+ }
23
+ if (platform.length > 0) {
24
+ ua += ` (${platform.join('; ')})`;
25
+ }
26
+ // `navigator.userAgent` is available in Node.js 21 and later.
27
+ // It's also part of the WinterCG spec, so many edge runtimes provide it.
28
+ // https://common-min-api.proposal.wintercg.org/#requirements-for-navigatoruseragent
29
+ // @ts-ignore
30
+ if (typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string') {
31
+ // @ts-ignore
32
+ ua += ` ${navigator.userAgent}`;
33
+ // @ts-ignore
34
+ }
35
+ else if (typeof globalThis.EdgeRuntime === 'string') {
36
+ ua += ` EdgeRuntime`;
37
+ // Older Node.js versions don't have `navigator.userAgent`, so we have to use `process.version`.
38
+ }
39
+ else if (typeof process !== 'undefined' && typeof process.version === 'string') {
40
+ ua += ` Node.js/${process.version}`;
41
+ }
42
+ return ua;
43
+ }
44
+ class Client {
45
+ constructor() {
46
+ this.config = {
47
+ endpoint: 'https://cloud.appconda.io/v1',
48
+ selfSigned: false,
49
+ project: '',
50
+ mode: '',
51
+ key: '',
52
+ jwt: '',
53
+ locale: '',
54
+ session: '',
55
+ forwardeduseragent: '',
56
+ };
57
+ this.headers = {
58
+ 'x-sdk-name': 'Node.js',
59
+ 'x-sdk-platform': 'server',
60
+ 'x-sdk-language': 'nodejs',
61
+ 'x-sdk-version': '14.1.0',
62
+ 'user-agent': getUserAgent(),
63
+ 'X-Appconda-Response-Format': '1.6.0',
64
+ };
65
+ }
66
+ /**
67
+ * Set Endpoint
68
+ *
69
+ * Your project endpoint
70
+ *
71
+ * @param {string} endpoint
72
+ *
73
+ * @returns {this}
74
+ */
75
+ setEndpoint(endpoint) {
76
+ this.config.endpoint = endpoint;
77
+ return this;
78
+ }
79
+ /**
80
+ * Set self-signed
81
+ *
82
+ * @param {boolean} selfSigned
83
+ *
84
+ * @returns {this}
85
+ */
86
+ setSelfSigned(selfSigned) {
87
+ // @ts-ignore
88
+ if (typeof globalThis.EdgeRuntime !== 'undefined') {
89
+ console.warn('setSelfSigned is not supported in edge runtimes.');
90
+ }
91
+ this.config.selfSigned = selfSigned;
92
+ return this;
93
+ }
94
+ /**
95
+ * Add header
96
+ *
97
+ * @param {string} header
98
+ * @param {string} value
99
+ *
100
+ * @returns {this}
101
+ */
102
+ addHeader(header, value) {
103
+ this.headers[header.toLowerCase()] = value;
104
+ return this;
105
+ }
106
+ /**
107
+ * Set Project
108
+ *
109
+ * Your project ID
110
+ *
111
+ * @param value string
112
+ *
113
+ * @return {this}
114
+ */
115
+ setProject(value) {
116
+ this.headers['X-Appconda-Project'] = value;
117
+ this.config.project = value;
118
+ return this;
119
+ }
120
+ /**
121
+ * Set Mode
122
+ *
123
+ * @param value string
124
+ *
125
+ * @return {this}
126
+ */
127
+ setMode(value) {
128
+ this.headers['X-Appconda-Mode'] = value;
129
+ this.config.mode = value;
130
+ return this;
131
+ }
132
+ /**
133
+ * Set Key
134
+ *
135
+ * Your secret API key
136
+ *
137
+ * @param value string
138
+ *
139
+ * @return {this}
140
+ */
141
+ setKey(value) {
142
+ this.headers['X-Appconda-Key'] = value;
143
+ this.config.key = value;
144
+ return this;
145
+ }
146
+ /**
147
+ * Set JWT
148
+ *
149
+ * Your secret JSON Web Token
150
+ *
151
+ * @param value string
152
+ *
153
+ * @return {this}
154
+ */
155
+ setJWT(value) {
156
+ this.headers['X-Appconda-JWT'] = value;
157
+ this.config.jwt = value;
158
+ return this;
159
+ }
160
+ /**
161
+ * Set Locale
162
+ *
163
+ * @param value string
164
+ *
165
+ * @return {this}
166
+ */
167
+ setLocale(value) {
168
+ this.headers['X-Appconda-Locale'] = value;
169
+ this.config.locale = value;
170
+ return this;
171
+ }
172
+ /**
173
+ * Set Session
174
+ *
175
+ * The user session to authenticate with
176
+ *
177
+ * @param value string
178
+ *
179
+ * @return {this}
180
+ */
181
+ setSession(value) {
182
+ this.headers['X-Appconda-Session'] = value;
183
+ this.config.session = value;
184
+ return this;
185
+ }
186
+ /**
187
+ * Set ForwardedUserAgent
188
+ *
189
+ * The user agent string of the client that made the request
190
+ *
191
+ * @param value string
192
+ *
193
+ * @return {this}
194
+ */
195
+ setForwardedUserAgent(value) {
196
+ this.headers['X-Forwarded-User-Agent'] = value;
197
+ this.config.forwardeduseragent = value;
198
+ return this;
199
+ }
200
+ setFallbackCookies(value) {
201
+ this.headers['X-Fallback-Cookies'] = value;
202
+ //this.config.forwardeduseragent = value;
203
+ return this;
204
+ }
205
+ prepareRequest(method, url, headers = {}, params = {}) {
206
+ method = method.toUpperCase();
207
+ headers = Object.assign({}, this.headers, headers);
208
+ let options = {
209
+ method,
210
+ headers,
211
+ ...createAgent(this.config.endpoint, { rejectUnauthorized: !this.config.selfSigned }),
212
+ };
213
+ if (method === 'GET') {
214
+ for (const [key, value] of Object.entries(Client.flatten(params))) {
215
+ url.searchParams.append(key, value);
216
+ }
217
+ }
218
+ else {
219
+ switch (headers['content-type']) {
220
+ case 'application/json':
221
+ options.body = JSON.stringify(params);
222
+ break;
223
+ case 'multipart/form-data':
224
+ const formData = new FormData();
225
+ for (const [key, value] of Object.entries(params)) {
226
+ if (value instanceof File) {
227
+ formData.append(key, value, value.name);
228
+ }
229
+ else if (Array.isArray(value)) {
230
+ for (const nestedValue of value) {
231
+ formData.append(`${key}[]`, nestedValue);
232
+ }
233
+ }
234
+ else {
235
+ formData.append(key, value);
236
+ }
237
+ }
238
+ options.body = formData;
239
+ delete headers['content-type'];
240
+ break;
241
+ }
242
+ }
243
+ return { uri: url.toString(), options };
244
+ }
245
+ async chunkedUpload(method, url, headers = {}, originalPayload = {}, onProgress) {
246
+ const file = Object.values(originalPayload).find((value) => value instanceof File);
247
+ if (file.size <= Client.CHUNK_SIZE) {
248
+ return await this.call(method, url, headers, originalPayload);
249
+ }
250
+ let start = 0;
251
+ let response = null;
252
+ while (start < file.size) {
253
+ let end = start + Client.CHUNK_SIZE; // Prepare end for the next chunk
254
+ if (end >= file.size) {
255
+ end = file.size; // Adjust for the last chunk to include the last byte
256
+ }
257
+ headers['content-range'] = `bytes ${start}-${end - 1}/${file.size}`;
258
+ const chunk = file.slice(start, end);
259
+ let payload = { ...originalPayload, file: new File([chunk], file.name) };
260
+ response = await this.call(method, url, headers, payload);
261
+ if (onProgress && typeof onProgress === 'function') {
262
+ onProgress({
263
+ $id: response.$id,
264
+ progress: Math.round((end / file.size) * 100),
265
+ sizeUploaded: end,
266
+ chunksTotal: Math.ceil(file.size / Client.CHUNK_SIZE),
267
+ chunksUploaded: Math.ceil(end / Client.CHUNK_SIZE)
268
+ });
269
+ }
270
+ if (response && response.$id) {
271
+ headers['x-appconda-id'] = response.$id;
272
+ }
273
+ start = end;
274
+ }
275
+ return response;
276
+ }
277
+ async redirect(method, url, headers = {}, params = {}) {
278
+ const { uri, options } = this.prepareRequest(method, url, headers, params);
279
+ const response = await fetch(uri, {
280
+ ...options,
281
+ redirect: 'manual'
282
+ });
283
+ if (response.status !== 301 && response.status !== 302) {
284
+ throw new AppcondaException('Invalid redirect', response.status);
285
+ }
286
+ return response.headers.get('location') || '';
287
+ }
288
+ async call(method, url, headers = {}, params = {}, responseType = 'json') {
289
+ const { uri, options } = this.prepareRequest(method, url, headers, params);
290
+ let data = null;
291
+ try {
292
+ const response = await fetch(uri, options);
293
+ const warnings = response.headers.get('x-appconda-warning');
294
+ if (warnings) {
295
+ warnings.split(';').forEach((warning) => console.warn('Warning: ' + warning));
296
+ }
297
+ if (response.headers.get('content-type')?.includes('application/json')) {
298
+ data = await response.json();
299
+ }
300
+ else if (responseType === 'arrayBuffer') {
301
+ data = await response.arrayBuffer();
302
+ }
303
+ else {
304
+ data = {
305
+ message: await response.text()
306
+ };
307
+ }
308
+ if (400 <= response.status) {
309
+ throw new AppcondaException(data?.message, response.status, data?.type, data);
310
+ }
311
+ return data;
312
+ }
313
+ catch (e) {
314
+ console.error(e);
315
+ throw e;
316
+ }
317
+ }
318
+ static flatten(data, prefix = '') {
319
+ let output = {};
320
+ for (const [key, value] of Object.entries(data)) {
321
+ let finalKey = prefix ? prefix + '[' + key + ']' : key;
322
+ if (Array.isArray(value)) {
323
+ output = { ...output, ...Client.flatten(value, finalKey) };
324
+ }
325
+ else {
326
+ output[finalKey] = value;
327
+ }
328
+ }
329
+ return output;
330
+ }
331
+ }
332
+ Client.CHUNK_SIZE = 1024 * 1024 * 5;
333
+ export { Client, AppcondaException };
334
+ export { Query } from './query';
@@ -0,0 +1,78 @@
1
+ import { Services } from "@/Services";
2
+ function stableStringify(obj) {
3
+ if (obj && typeof obj === "object" && !Array.isArray(obj)) {
4
+ return `{${Object.keys(obj).sort().map(key => `"${key}":${stableStringify(obj[key])}`).join(",")}}`;
5
+ }
6
+ return JSON.stringify(obj);
7
+ }
8
+ function generateCacheKey(...args) {
9
+ return stableStringify(args);
10
+ }
11
+ // console.log(generateCacheKey("user", 123, true, { role: "admin", permissions: ["read", "write"] }));
12
+ // console.log(generateCacheKey("user", 123, true, { permissions: ["read", "write"], role: "admin" }));
13
+ export function Cache( /* cacheKey?: string | string[] */) {
14
+ return function (target, propertyKey, descriptor) {
15
+ const originalMethod = descriptor.value;
16
+ descriptor.value = async function (...args) {
17
+ const className = target.constructor.name.toLowerCase();
18
+ // Metod adı
19
+ const methodName = propertyKey.toLowerCase();
20
+ const cacheKeys = [target.__cacheKeys || []].reverse();
21
+ console.log("Defined cache keys:", cacheKeys);
22
+ const cacheKey = ['admin', className, propertyKey];
23
+ if (cacheKeys.length > 0) {
24
+ for (let i = 0; i < cacheKeys.length; i++) {
25
+ const keyIndex = cacheKeys[i]['parameterIndex'];
26
+ if (args != null && args[keyIndex] != null) {
27
+ const key = args[keyIndex].toString();
28
+ cacheKey.push(key);
29
+ }
30
+ }
31
+ }
32
+ else if (args.length > 0) { //cacheKey belirtilmemisse tum parametreleri kullan
33
+ for (let i = 0; i < args.length; i++) {
34
+ const key = args[i].toString();
35
+ cacheKey.push(key);
36
+ }
37
+ }
38
+ // Cache key'i dizeye dönüştür
39
+ // const key = Array.isArray(cacheKey) ? cacheKey.join(':') : cacheKey;
40
+ // Cache'ten veri al
41
+ let cachedData = await Services.Cache.load(cacheKey);
42
+ if (cachedData != null) {
43
+ return cachedData; // Cache'teki veriyi döndür
44
+ }
45
+ // Orijinal metodu çağır ve dönen değeri cache'e kaydet
46
+ const result = await originalMethod.apply(this, args);
47
+ // Cache'e kaydet (asenkron yapılır, beklenmez)
48
+ Services.Cache.save(cacheKey, result);
49
+ console.log('------------------------------Cache executed..');
50
+ return result;
51
+ };
52
+ return descriptor;
53
+ };
54
+ }
55
+ /* const cacheKeys: any[] = target.__cacheKeys || [];
56
+ console.log("Defined cache keys:", [...cacheKeys].reverse());
57
+
58
+ const className = target.constructor.name.toLowerCase();
59
+
60
+ // Metod adı
61
+ const methodName = propertyKey.toLowerCase();
62
+
63
+ debugger
64
+ const cacheKey = ['admin', className, propertyKey];
65
+ if (cacheKey.length > 0) {
66
+ for (let i = 0; i < cacheKeys.length; i++) {
67
+ const keyIndex = cacheKeys[i]['parameterIndex'];
68
+ if (args != null && args[keyIndex] != null) {
69
+ const key = args[keyIndex].toString();
70
+ cacheKey.push(key);
71
+ }
72
+ }
73
+ } else if (args.length > 0) { //cacheKey belirtilmemisse tum parametreleri kullan
74
+ for (let i = 0; i < args.length; i++) {
75
+ const key = args[i].toString();
76
+ cacheKey.push(key);
77
+ }
78
+ } */
@@ -0,0 +1,8 @@
1
+ export function CacheKey() {
2
+ return function (target, propertyKey, parameterIndex) {
3
+ if (!target.__cacheKeys) {
4
+ target.__cacheKeys = [];
5
+ }
6
+ target.__cacheKeys.push({ propertyKey, parameterIndex });
7
+ };
8
+ }
@@ -0,0 +1,46 @@
1
+ import { Services } from "@/Services";
2
+ export function Invalidate(keys) {
3
+ return function (target, propertyKey, descriptor) {
4
+ const originalMethod = descriptor.value;
5
+ descriptor.value = async function (...args) {
6
+ const className = target.constructor.name.toLowerCase();
7
+ // Metod adı
8
+ const methodName = propertyKey.toLowerCase();
9
+ const cacheKey = ['admin', className];
10
+ // Orijinal metodu çağır ve dönen değeri cache'e kaydet
11
+ const result = await originalMethod.apply(this, args);
12
+ // Cache'e kaydet (asenkron yapılır, beklenmez)
13
+ for (let key of keys) {
14
+ Services.Cache.purge([...cacheKey, key]);
15
+ Services.Cache.delWithStart([...cacheKey, key]);
16
+ }
17
+ console.log('------------------------------Cache deleted.');
18
+ return result;
19
+ };
20
+ return descriptor;
21
+ };
22
+ }
23
+ /* const cacheKeys: any[] = target.__cacheKeys || [];
24
+ console.log("Defined cache keys:", [...cacheKeys].reverse());
25
+
26
+ const className = target.constructor.name.toLowerCase();
27
+
28
+ // Metod adı
29
+ const methodName = propertyKey.toLowerCase();
30
+
31
+ debugger
32
+ const cacheKey = ['admin', className, propertyKey];
33
+ if (cacheKey.length > 0) {
34
+ for (let i = 0; i < cacheKeys.length; i++) {
35
+ const keyIndex = cacheKeys[i]['parameterIndex'];
36
+ if (args != null && args[keyIndex] != null) {
37
+ const key = args[keyIndex].toString();
38
+ cacheKey.push(key);
39
+ }
40
+ }
41
+ } else if (args.length > 0) { //cacheKey belirtilmemisse tum parametreleri kullan
42
+ for (let i = 0; i < args.length; i++) {
43
+ const key = args[i].toString();
44
+ cacheKey.push(key);
45
+ }
46
+ } */
@@ -0,0 +1,14 @@
1
+ export var ApiService;
2
+ (function (ApiService) {
3
+ ApiService["Account"] = "account";
4
+ ApiService["Avatars"] = "avatars";
5
+ ApiService["Databases"] = "databases";
6
+ ApiService["Locale"] = "locale";
7
+ ApiService["Health"] = "health";
8
+ ApiService["Storage"] = "storage";
9
+ ApiService["Teams"] = "teams";
10
+ ApiService["Users"] = "users";
11
+ ApiService["Functions"] = "functions";
12
+ ApiService["Graphql"] = "graphql";
13
+ ApiService["Messaging"] = "messaging";
14
+ })(ApiService || (ApiService = {}));
@@ -0,0 +1,6 @@
1
+ export var Api;
2
+ (function (Api) {
3
+ Api["Rest"] = "rest";
4
+ Api["Graphql"] = "graphql";
5
+ Api["Realtime"] = "realtime";
6
+ })(Api || (Api = {}));
@@ -0,0 +1,10 @@
1
+ export var AuthMethod;
2
+ (function (AuthMethod) {
3
+ AuthMethod["Emailpassword"] = "email-password";
4
+ AuthMethod["Magicurl"] = "magic-url";
5
+ AuthMethod["Emailotp"] = "email-otp";
6
+ AuthMethod["Anonymous"] = "anonymous";
7
+ AuthMethod["Invites"] = "invites";
8
+ AuthMethod["Jwt"] = "jwt";
9
+ AuthMethod["Phone"] = "phone";
10
+ })(AuthMethod || (AuthMethod = {}));
@@ -0,0 +1,7 @@
1
+ export var AuthenticationFactor;
2
+ (function (AuthenticationFactor) {
3
+ AuthenticationFactor["Email"] = "email";
4
+ AuthenticationFactor["Phone"] = "phone";
5
+ AuthenticationFactor["Totp"] = "totp";
6
+ AuthenticationFactor["Recoverycode"] = "recoverycode";
7
+ })(AuthenticationFactor || (AuthenticationFactor = {}));
@@ -0,0 +1,4 @@
1
+ export var AuthenticatorType;
2
+ (function (AuthenticatorType) {
3
+ AuthenticatorType["Totp"] = "totp";
4
+ })(AuthenticatorType || (AuthenticatorType = {}));
@@ -0,0 +1,17 @@
1
+ export var Browser;
2
+ (function (Browser) {
3
+ Browser["AvantBrowser"] = "aa";
4
+ Browser["AndroidWebViewBeta"] = "an";
5
+ Browser["GoogleChrome"] = "ch";
6
+ Browser["GoogleChromeIOS"] = "ci";
7
+ Browser["GoogleChromeMobile"] = "cm";
8
+ Browser["Chromium"] = "cr";
9
+ Browser["MozillaFirefox"] = "ff";
10
+ Browser["Safari"] = "sf";
11
+ Browser["MobileSafari"] = "mf";
12
+ Browser["MicrosoftEdge"] = "ps";
13
+ Browser["MicrosoftEdgeIOS"] = "oi";
14
+ Browser["OperaMini"] = "om";
15
+ Browser["Opera"] = "op";
16
+ Browser["OperaNext"] = "on";
17
+ })(Browser || (Browser = {}));
@@ -0,0 +1,6 @@
1
+ export var Compression;
2
+ (function (Compression) {
3
+ Compression["None"] = "none";
4
+ Compression["Gzip"] = "gzip";
5
+ Compression["Zstd"] = "zstd";
6
+ })(Compression || (Compression = {}));
@@ -0,0 +1,19 @@
1
+ export var CreditCard;
2
+ (function (CreditCard) {
3
+ CreditCard["AmericanExpress"] = "amex";
4
+ CreditCard["Argencard"] = "argencard";
5
+ CreditCard["Cabal"] = "cabal";
6
+ CreditCard["Cencosud"] = "cencosud";
7
+ CreditCard["DinersClub"] = "diners";
8
+ CreditCard["Discover"] = "discover";
9
+ CreditCard["Elo"] = "elo";
10
+ CreditCard["Hipercard"] = "hipercard";
11
+ CreditCard["JCB"] = "jcb";
12
+ CreditCard["Mastercard"] = "mastercard";
13
+ CreditCard["Naranja"] = "naranja";
14
+ CreditCard["TarjetaShopping"] = "targeta-shopping";
15
+ CreditCard["UnionChinaPay"] = "union-china-pay";
16
+ CreditCard["Visa"] = "visa";
17
+ CreditCard["MIR"] = "mir";
18
+ CreditCard["Maestro"] = "maestro";
19
+ })(CreditCard || (CreditCard = {}));
@@ -0,0 +1,6 @@
1
+ export var DatabaseUsageRange;
2
+ (function (DatabaseUsageRange) {
3
+ DatabaseUsageRange["TwentyFourHours"] = "24h";
4
+ DatabaseUsageRange["ThirtyDays"] = "30d";
5
+ DatabaseUsageRange["NinetyDays"] = "90d";
6
+ })(DatabaseUsageRange || (DatabaseUsageRange = {}));