@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
@@ -0,0 +1,16 @@
1
+ import { File } from "node-fetch-native-with-agent";
2
+ import { realpathSync, readFileSync } from "fs";
3
+ export class InputFile {
4
+ static fromBuffer(parts, name) {
5
+ return new File([parts], name);
6
+ }
7
+ static fromPath(path, name) {
8
+ const realPath = realpathSync(path);
9
+ const contents = readFileSync(realPath);
10
+ return this.fromBuffer(contents, name);
11
+ }
12
+ static fromPlainText(content, name) {
13
+ const arrayBytes = new TextEncoder().encode(content);
14
+ return this.fromBuffer(arrayBytes, name);
15
+ }
16
+ }
@@ -0,0 +1,55 @@
1
+ export class Registry {
2
+ constructor() {
3
+ /**
4
+ * List of all callbacks
5
+ */
6
+ this.callbacks = {};
7
+ /**
8
+ * List of all fresh resources
9
+ */
10
+ this.fresh = {};
11
+ /**
12
+ * List of all connections
13
+ */
14
+ this.registry = {
15
+ 'default': {},
16
+ };
17
+ /**
18
+ * Current context
19
+ */
20
+ this._context = 'default';
21
+ }
22
+ /**
23
+ * Set a new connection callback
24
+ */
25
+ set(name, callback, fresh = false) {
26
+ if (this.registry[this._context].hasOwnProperty(name)) {
27
+ delete this.registry[this._context][name];
28
+ }
29
+ this.fresh[name] = fresh;
30
+ this.callbacks[name] = callback;
31
+ return this;
32
+ }
33
+ /**
34
+ * If connection has been created returns it, otherwise create and then return it
35
+ */
36
+ get(name, fresh = false) {
37
+ if (!this.registry[this._context].hasOwnProperty(name) || fresh || this.fresh[name]) {
38
+ if (!this.callbacks.hasOwnProperty(name)) {
39
+ throw new Error(`No callback named "${name}" found when trying to create connection`);
40
+ }
41
+ this.registry[this._context][name] = this.callbacks[name]();
42
+ }
43
+ return this.registry[this._context][name];
44
+ }
45
+ /**
46
+ * Set the current context
47
+ */
48
+ context(name) {
49
+ if (!this.registry.hasOwnProperty(name)) {
50
+ this.registry[name] = {};
51
+ }
52
+ this._context = name;
53
+ return this;
54
+ }
55
+ }
@@ -0,0 +1 @@
1
+ export * from './Registry';
package/dist/models.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Helper class to generate permission strings for resources.
3
+ */
4
+ export class Permission {
5
+ }
6
+ /**
7
+ * Generate read permission string for the provided role.
8
+ *
9
+ * @param {string} role
10
+ * @returns {string}
11
+ */
12
+ Permission.read = (role) => {
13
+ return `read("${role}")`;
14
+ };
15
+ /**
16
+ * Generate write permission string for the provided role.
17
+ *
18
+ * This is an alias of update, delete, and possibly create.
19
+ * Don't use write in combination with update, delete, or create.
20
+ *
21
+ * @param {string} role
22
+ * @returns {string}
23
+ */
24
+ Permission.write = (role) => {
25
+ return `write("${role}")`;
26
+ };
27
+ /**
28
+ * Generate create permission string for the provided role.
29
+ *
30
+ * @param {string} role
31
+ * @returns {string}
32
+ */
33
+ Permission.create = (role) => {
34
+ return `create("${role}")`;
35
+ };
36
+ /**
37
+ * Generate update permission string for the provided role.
38
+ *
39
+ * @param {string} role
40
+ * @returns {string}
41
+ */
42
+ Permission.update = (role) => {
43
+ return `update("${role}")`;
44
+ };
45
+ /**
46
+ * Generate delete permission string for the provided role.
47
+ *
48
+ * @param {string} role
49
+ * @returns {string}
50
+ */
51
+ Permission.delete = (role) => {
52
+ return `delete("${role}")`;
53
+ };
package/dist/query.js ADDED
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Helper class to generate query strings.
3
+ */
4
+ export class Query {
5
+ /**
6
+ * Constructor for Query class.
7
+ *
8
+ * @param {string} method
9
+ * @param {AttributesTypes} attribute
10
+ * @param {QueryTypes} values
11
+ */
12
+ constructor(method, attribute, values) {
13
+ this.method = method;
14
+ this.attribute = attribute;
15
+ if (values !== undefined) {
16
+ if (Array.isArray(values)) {
17
+ this.values = values;
18
+ }
19
+ else {
20
+ this.values = [values];
21
+ }
22
+ }
23
+ }
24
+ /**
25
+ * Convert the query object to a JSON string.
26
+ *
27
+ * @returns {string}
28
+ */
29
+ toString() {
30
+ return JSON.stringify({
31
+ method: this.method,
32
+ attribute: this.attribute,
33
+ values: this.values,
34
+ });
35
+ }
36
+ }
37
+ /**
38
+ * Filter resources where attribute is equal to value.
39
+ *
40
+ * @param {string} attribute
41
+ * @param {QueryTypes} value
42
+ * @returns {string}
43
+ */
44
+ Query.equal = (attribute, value) => new Query("equal", attribute, value).toString();
45
+ /**
46
+ * Filter resources where attribute is not equal to value.
47
+ *
48
+ * @param {string} attribute
49
+ * @param {QueryTypes} value
50
+ * @returns {string}
51
+ */
52
+ Query.notEqual = (attribute, value) => new Query("notEqual", attribute, value).toString();
53
+ /**
54
+ * Filter resources where attribute is less than value.
55
+ *
56
+ * @param {string} attribute
57
+ * @param {QueryTypes} value
58
+ * @returns {string}
59
+ */
60
+ Query.lessThan = (attribute, value) => new Query("lessThan", attribute, value).toString();
61
+ /**
62
+ * Filter resources where attribute is less than or equal to value.
63
+ *
64
+ * @param {string} attribute
65
+ * @param {QueryTypes} value
66
+ * @returns {string}
67
+ */
68
+ Query.lessThanEqual = (attribute, value) => new Query("lessThanEqual", attribute, value).toString();
69
+ /**
70
+ * Filter resources where attribute is greater than value.
71
+ *
72
+ * @param {string} attribute
73
+ * @param {QueryTypes} value
74
+ * @returns {string}
75
+ */
76
+ Query.greaterThan = (attribute, value) => new Query("greaterThan", attribute, value).toString();
77
+ /**
78
+ * Filter resources where attribute is greater than or equal to value.
79
+ *
80
+ * @param {string} attribute
81
+ * @param {QueryTypes} value
82
+ * @returns {string}
83
+ */
84
+ Query.greaterThanEqual = (attribute, value) => new Query("greaterThanEqual", attribute, value).toString();
85
+ /**
86
+ * Filter resources where attribute is null.
87
+ *
88
+ * @param {string} attribute
89
+ * @returns {string}
90
+ */
91
+ Query.isNull = (attribute) => new Query("isNull", attribute).toString();
92
+ /**
93
+ * Filter resources where attribute is not null.
94
+ *
95
+ * @param {string} attribute
96
+ * @returns {string}
97
+ */
98
+ Query.isNotNull = (attribute) => new Query("isNotNull", attribute).toString();
99
+ /**
100
+ * Filter resources where attribute is between start and end (inclusive).
101
+ *
102
+ * @param {string} attribute
103
+ * @param {string | number} start
104
+ * @param {string | number} end
105
+ * @returns {string}
106
+ */
107
+ Query.between = (attribute, start, end) => new Query("between", attribute, [start, end]).toString();
108
+ /**
109
+ * Filter resources where attribute starts with value.
110
+ *
111
+ * @param {string} attribute
112
+ * @param {string} value
113
+ * @returns {string}
114
+ */
115
+ Query.startsWith = (attribute, value) => new Query("startsWith", attribute, value).toString();
116
+ /**
117
+ * Filter resources where attribute ends with value.
118
+ *
119
+ * @param {string} attribute
120
+ * @param {string} value
121
+ * @returns {string}
122
+ */
123
+ Query.endsWith = (attribute, value) => new Query("endsWith", attribute, value).toString();
124
+ /**
125
+ * Specify which attributes should be returned by the API call.
126
+ *
127
+ * @param {string[]} attributes
128
+ * @returns {string}
129
+ */
130
+ Query.select = (attributes) => new Query("select", undefined, attributes).toString();
131
+ /**
132
+ * Filter resources by searching attribute for value.
133
+ * A fulltext index on attribute is required for this query to work.
134
+ *
135
+ * @param {string} attribute
136
+ * @param {string} value
137
+ * @returns {string}
138
+ */
139
+ Query.search = (attribute, value) => new Query("search", attribute, value).toString();
140
+ /**
141
+ * Sort results by attribute descending.
142
+ *
143
+ * @param {string} attribute
144
+ * @returns {string}
145
+ */
146
+ Query.orderDesc = (attribute) => new Query("orderDesc", attribute).toString();
147
+ /**
148
+ * Sort results by attribute ascending.
149
+ *
150
+ * @param {string} attribute
151
+ * @returns {string}
152
+ */
153
+ Query.orderAsc = (attribute) => new Query("orderAsc", attribute).toString();
154
+ /**
155
+ * Return results after documentId.
156
+ *
157
+ * @param {string} documentId
158
+ * @returns {string}
159
+ */
160
+ Query.cursorAfter = (documentId) => new Query("cursorAfter", undefined, documentId).toString();
161
+ /**
162
+ * Return results before documentId.
163
+ *
164
+ * @param {string} documentId
165
+ * @returns {string}
166
+ */
167
+ Query.cursorBefore = (documentId) => new Query("cursorBefore", undefined, documentId).toString();
168
+ /**
169
+ * Return only limit results.
170
+ *
171
+ * @param {number} limit
172
+ * @returns {string}
173
+ */
174
+ Query.limit = (limit) => new Query("limit", undefined, limit).toString();
175
+ /**
176
+ * Filter resources by skipping the first offset results.
177
+ *
178
+ * @param {number} offset
179
+ * @returns {string}
180
+ */
181
+ Query.offset = (offset) => new Query("offset", undefined, offset).toString();
182
+ /**
183
+ * Filter resources where attribute contains the specified value.
184
+ *
185
+ * @param {string} attribute
186
+ * @param {string | string[]} value
187
+ * @returns {string}
188
+ */
189
+ Query.contains = (attribute, value) => new Query("contains", attribute, value).toString();
190
+ /**
191
+ * Combine multiple queries using logical OR operator.
192
+ *
193
+ * @param {string[]} queries
194
+ * @returns {string}
195
+ */
196
+ Query.or = (queries) => new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString();
197
+ /**
198
+ * Combine multiple queries using logical AND operator.
199
+ *
200
+ * @param {string[]} queries
201
+ * @returns {string}
202
+ */
203
+ Query.and = (queries) => new Query("and", undefined, queries.map((query) => JSON.parse(query))).toString();
package/dist/role.js ADDED
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Helper class to generate role strings for `Permission`.
3
+ */
4
+ export class Role {
5
+ /**
6
+ * Grants access to anyone.
7
+ *
8
+ * This includes authenticated and unauthenticated users.
9
+ *
10
+ * @returns {string}
11
+ */
12
+ static any() {
13
+ return 'any';
14
+ }
15
+ /**
16
+ * Grants access to a specific user by user ID.
17
+ *
18
+ * You can optionally pass verified or unverified for
19
+ * `status` to target specific types of users.
20
+ *
21
+ * @param {string} id
22
+ * @param {string} status
23
+ * @returns {string}
24
+ */
25
+ static user(id, status = '') {
26
+ if (status === '') {
27
+ return `user:${id}`;
28
+ }
29
+ return `user:${id}/${status}`;
30
+ }
31
+ /**
32
+ * Grants access to any authenticated or anonymous user.
33
+ *
34
+ * You can optionally pass verified or unverified for
35
+ * `status` to target specific types of users.
36
+ *
37
+ * @param {string} status
38
+ * @returns {string}
39
+ */
40
+ static users(status = '') {
41
+ if (status === '') {
42
+ return 'users';
43
+ }
44
+ return `users/${status}`;
45
+ }
46
+ /**
47
+ * Grants access to any guest user without a session.
48
+ *
49
+ * Authenticated users don't have access to this role.
50
+ *
51
+ * @returns {string}
52
+ */
53
+ static guests() {
54
+ return 'guests';
55
+ }
56
+ /**
57
+ * Grants access to a team by team ID.
58
+ *
59
+ * You can optionally pass a role for `role` to target
60
+ * team members with the specified role.
61
+ *
62
+ * @param {string} id
63
+ * @param {string} role
64
+ * @returns {string}
65
+ */
66
+ static team(id, role = '') {
67
+ if (role === '') {
68
+ return `team:${id}`;
69
+ }
70
+ return `team:${id}/${role}`;
71
+ }
72
+ /**
73
+ * Grants access to a specific member of a team.
74
+ *
75
+ * When the member is removed from the team, they will
76
+ * no longer have access.
77
+ *
78
+ * @param {string} id
79
+ * @returns {string}
80
+ */
81
+ static member(id) {
82
+ return `member:${id}`;
83
+ }
84
+ /**
85
+ * Grants access to a user with the specified label.
86
+ *
87
+ * @param {string} name
88
+ * @returns {string}
89
+ */
90
+ static label(name) {
91
+ return `label:${name}`;
92
+ }
93
+ }
@@ -0,0 +1,13 @@
1
+ export class ServiceClient {
2
+ constructor(client) {
3
+ this.client = client;
4
+ }
5
+ async actionCall(actionName, payload) {
6
+ const apiPath = `/service/registry/${this.getServiceName()}/${actionName}`;
7
+ const uri = new URL(this.client.config.endpoint + apiPath);
8
+ const apiHeaders = {
9
+ 'content-type': 'application/json',
10
+ };
11
+ return await this.client.call('post', uri, apiHeaders, payload);
12
+ }
13
+ }
@@ -0,0 +1,22 @@
1
+ export class Service {
2
+ constructor(client) {
3
+ this.client = client;
4
+ }
5
+ static flatten(data, prefix = '') {
6
+ let output = {};
7
+ for (const [key, value] of Object.entries(data)) {
8
+ let finalKey = prefix ? prefix + '[' + key + ']' : key;
9
+ if (Array.isArray(value)) {
10
+ output = { ...output, ...Service.flatten(value, finalKey) };
11
+ }
12
+ else {
13
+ output[finalKey] = value;
14
+ }
15
+ }
16
+ return output;
17
+ }
18
+ }
19
+ /**
20
+ * The size for chunked uploads in bytes.
21
+ */
22
+ Service.CHUNK_SIZE = 5 * 1024 * 1024; // 5MB