mlcl 1.0.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.
Files changed (195) hide show
  1. package/.eslintignore +31 -0
  2. package/.eslintrc.json +54 -0
  3. package/LICENSE +200 -0
  4. package/README.md +101 -0
  5. package/babel.config.json +10 -0
  6. package/build/API/authorization.js +107 -0
  7. package/build/API/client.js +11 -0
  8. package/build/API/index.js +8 -0
  9. package/build/API/molecule/index.js +11 -0
  10. package/build/API/molecule/types.js +6 -0
  11. package/build/API/resource/device/index.js +12 -0
  12. package/build/API/resource/device/types.js +6 -0
  13. package/build/API/resource/device/utilities/confirmSshKey.js +20 -0
  14. package/build/API/resource/device/utilities/index.js +7 -0
  15. package/build/API/resource/device/utilities/sendSshKey.js +64 -0
  16. package/build/API/resource/index.js +10 -0
  17. package/build/API/resource/molecule/index.js +12 -0
  18. package/build/API/resource/molecule/types.js +6 -0
  19. package/build/API/resource/molecule/utilities/getPlan.js +15 -0
  20. package/build/API/resource/molecule/utilities/index.js +6 -0
  21. package/build/API/resource/payment/index.js +9 -0
  22. package/build/API/resource/payment/plans.js +28 -0
  23. package/build/API/resource/payment/platform.js +7 -0
  24. package/build/API/resource/payment/platforms/apple/index.js +21 -0
  25. package/build/API/resource/payment/platforms/apple/plans/appleMonthly.js +17 -0
  26. package/build/API/resource/payment/platforms/apple/plans/appleYearly.js +18 -0
  27. package/build/API/resource/payment/platforms/apple/plans/index.js +7 -0
  28. package/build/API/resource/payment/platforms/google/index.js +21 -0
  29. package/build/API/resource/payment/platforms/google/plans/googleMonthly.js +17 -0
  30. package/build/API/resource/payment/platforms/google/plans/googleYearly.js +18 -0
  31. package/build/API/resource/payment/platforms/google/plans/index.js +7 -0
  32. package/build/API/resource/payment/platforms/index.js +8 -0
  33. package/build/API/resource/payment/platforms/stripe/index.js +25 -0
  34. package/build/API/resource/payment/platforms/stripe/plans/index.js +11 -0
  35. package/build/API/resource/payment/platforms/stripe/plans/stripeBusinessMolecule.js +21 -0
  36. package/build/API/resource/payment/platforms/stripe/plans/stripeMonthly.js +18 -0
  37. package/build/API/resource/payment/platforms/stripe/plans/stripeMonthlyMolecule.js +18 -0
  38. package/build/API/resource/payment/platforms/stripe/plans/stripeSingleUseMolecule.js +19 -0
  39. package/build/API/resource/payment/platforms/stripe/plans/stripeUnlimitedUseMolecule.js +19 -0
  40. package/build/API/resource/payment/platforms/stripe/plans/stripeYearly.js +19 -0
  41. package/build/API/resource/payment/types.js +6 -0
  42. package/build/API/resource/types.js +6 -0
  43. package/build/API/resource/user/index.js +15 -0
  44. package/build/API/resource/user/types.js +6 -0
  45. package/build/API/resource/user/utilities/getPlan.js +12 -0
  46. package/build/API/resource/user/utilities/index.js +7 -0
  47. package/build/API/resource/user/utilities/logIn.js +60 -0
  48. package/build/cli.js +15 -0
  49. package/build/commands/add-ssh-key.js +24 -0
  50. package/build/commands/buy.js +70 -0
  51. package/build/commands/clone.js +329 -0
  52. package/build/commands/index.js +17 -0
  53. package/build/commands/info.js +33 -0
  54. package/build/commands/login.js +20 -0
  55. package/build/commands/logout.js +23 -0
  56. package/build/commands/molecule/index.js +11 -0
  57. package/build/commands/molecule/types.js +6 -0
  58. package/build/commands/remove-ssh-key.js +36 -0
  59. package/build/commands/select.js +98 -0
  60. package/build/commands/set-api-key.js +73 -0
  61. package/build/commands/subscribe.js +74 -0
  62. package/build/commands/unsubscribe.js +59 -0
  63. package/build/commands/utilities/asyncExec.js +6 -0
  64. package/build/commands/utilities/branchExists.js +13 -0
  65. package/build/commands/utilities/branchExistsSync.js +12 -0
  66. package/build/commands/utilities/checkoutSelectionBranch.js +49 -0
  67. package/build/commands/utilities/cherryPick.js +20 -0
  68. package/build/commands/utilities/cloneRepo.js +9 -0
  69. package/build/commands/utilities/convertNpmToYarn.js +60 -0
  70. package/build/commands/utilities/convertTypeDocToJSDoc.js +51 -0
  71. package/build/commands/utilities/convertTypeScriptToJavaScript.js +451 -0
  72. package/build/commands/utilities/enableMergeDrivers.js +50 -0
  73. package/build/commands/utilities/getCurrentBranch.js +11 -0
  74. package/build/commands/utilities/getCurrentBranchSync.js +7 -0
  75. package/build/commands/utilities/getRepoRootPath.js +7 -0
  76. package/build/commands/utilities/getRepoRootPathSync.js +13 -0
  77. package/build/commands/utilities/index.js +16 -0
  78. package/build/commands/utilities/npm-to-yarn.js +41 -0
  79. package/build/commands/utilities/ts-to-js.js +344 -0
  80. package/build/commands/version.js +14 -0
  81. package/build/commands/x-merge-json.js +33 -0
  82. package/build/config.js +5 -0
  83. package/build/environment.js +80 -0
  84. package/build/index.js +23 -0
  85. package/build/logger.js +12 -0
  86. package/build/pkg.js +5 -0
  87. package/build/repoConfig copy.js +5 -0
  88. package/build/repoConfig.js +5 -0
  89. package/build/types/global.js +6 -0
  90. package/build/types/index.js +6 -0
  91. package/build/userConfig.js +5 -0
  92. package/build/utilities/__tests__/getErrorMessage.js +26 -0
  93. package/build/utilities/__tests__/timeAgo.js +39 -0
  94. package/build/utilities/checkVersion.js +29 -0
  95. package/build/utilities/getErrorMessage.js +15 -0
  96. package/build/utilities/index.js +13 -0
  97. package/build/utilities/readConfig.js +19 -0
  98. package/build/utilities/readRepoConfig copy.js +20 -0
  99. package/build/utilities/readRepoConfig.js +19 -0
  100. package/build/utilities/readUserConfig.js +20 -0
  101. package/build/utilities/synchronizeUserConfig.js +25 -0
  102. package/build/utilities/timeAgo.js +42 -0
  103. package/build/utilities/userLoggedIn.js +24 -0
  104. package/build/utilities/writeConfig.js +8 -0
  105. package/build/utilities/writeRepoConfig copy.js +9 -0
  106. package/build/utilities/writeRepoConfig.js +10 -0
  107. package/build/utilities/writeUserConfig.js +11 -0
  108. package/jest.config.json +11 -0
  109. package/package.json +56 -0
  110. package/src/API/authorization.ts +143 -0
  111. package/src/API/client.ts +12 -0
  112. package/src/API/index.ts +10 -0
  113. package/src/API/resource/device/index.ts +27 -0
  114. package/src/API/resource/device/types.ts +80 -0
  115. package/src/API/resource/device/utilities/confirmSshKey.ts +25 -0
  116. package/src/API/resource/device/utilities/index.ts +8 -0
  117. package/src/API/resource/device/utilities/sendSshKey.ts +80 -0
  118. package/src/API/resource/index.ts +12 -0
  119. package/src/API/resource/molecule/index.ts +30 -0
  120. package/src/API/resource/molecule/types.ts +332 -0
  121. package/src/API/resource/molecule/utilities/getPlan.ts +21 -0
  122. package/src/API/resource/molecule/utilities/index.ts +7 -0
  123. package/src/API/resource/payment/index.ts +12 -0
  124. package/src/API/resource/payment/plans.ts +32 -0
  125. package/src/API/resource/payment/platform.ts +11 -0
  126. package/src/API/resource/payment/platforms/apple/index.ts +25 -0
  127. package/src/API/resource/payment/platforms/apple/plans/appleMonthly.ts +19 -0
  128. package/src/API/resource/payment/platforms/apple/plans/appleYearly.ts +20 -0
  129. package/src/API/resource/payment/platforms/apple/plans/index.ts +9 -0
  130. package/src/API/resource/payment/platforms/google/index.ts +25 -0
  131. package/src/API/resource/payment/platforms/google/plans/googleMonthly.ts +19 -0
  132. package/src/API/resource/payment/platforms/google/plans/googleYearly.ts +20 -0
  133. package/src/API/resource/payment/platforms/google/plans/index.ts +9 -0
  134. package/src/API/resource/payment/platforms/index.ts +10 -0
  135. package/src/API/resource/payment/platforms/stripe/index.ts +29 -0
  136. package/src/API/resource/payment/platforms/stripe/plans/index.ts +12 -0
  137. package/src/API/resource/payment/platforms/stripe/plans/stripeBusinessMolecule.ts +23 -0
  138. package/src/API/resource/payment/platforms/stripe/plans/stripeMonthly.ts +20 -0
  139. package/src/API/resource/payment/platforms/stripe/plans/stripeMonthlyMolecule.ts +20 -0
  140. package/src/API/resource/payment/platforms/stripe/plans/stripeSingleUseMolecule.ts +21 -0
  141. package/src/API/resource/payment/platforms/stripe/plans/stripeUnlimitedUseMolecule.ts +21 -0
  142. package/src/API/resource/payment/platforms/stripe/plans/stripeYearly.ts +21 -0
  143. package/src/API/resource/payment/types.ts +201 -0
  144. package/src/API/resource/types.ts +169 -0
  145. package/src/API/resource/user/index.ts +29 -0
  146. package/src/API/resource/user/types.ts +131 -0
  147. package/src/API/resource/user/utilities/getPlan.ts +16 -0
  148. package/src/API/resource/user/utilities/index.ts +8 -0
  149. package/src/API/resource/user/utilities/logIn.ts +71 -0
  150. package/src/commands/add-ssh-key.ts +30 -0
  151. package/src/commands/buy.ts +83 -0
  152. package/src/commands/clone.ts +363 -0
  153. package/src/commands/index.ts +19 -0
  154. package/src/commands/info.ts +40 -0
  155. package/src/commands/login.ts +24 -0
  156. package/src/commands/logout.ts +27 -0
  157. package/src/commands/remove-ssh-key.ts +42 -0
  158. package/src/commands/subscribe.ts +84 -0
  159. package/src/commands/unsubscribe.ts +67 -0
  160. package/src/commands/utilities/asyncExec.ts +7 -0
  161. package/src/commands/utilities/branchExists.ts +15 -0
  162. package/src/commands/utilities/checkoutSelectionBranch.ts +62 -0
  163. package/src/commands/utilities/cherryPick.ts +23 -0
  164. package/src/commands/utilities/cloneRepo.ts +10 -0
  165. package/src/commands/utilities/convertNpmToYarn.ts +71 -0
  166. package/src/commands/utilities/convertTypeDocToJSDoc.ts +55 -0
  167. package/src/commands/utilities/convertTypeScriptToJavaScript.ts +526 -0
  168. package/src/commands/utilities/enableMergeDrivers.ts +55 -0
  169. package/src/commands/utilities/getCurrentBranch.ts +14 -0
  170. package/src/commands/utilities/getRepoRootPathSync.ts +13 -0
  171. package/src/commands/utilities/index.ts +17 -0
  172. package/src/commands/version.ts +22 -0
  173. package/src/commands/x-merge-json.ts +41 -0
  174. package/src/environment.ts +88 -0
  175. package/src/index.ts +30 -0
  176. package/src/logger.ts +29 -0
  177. package/src/pkg.ts +11 -0
  178. package/src/repoConfig.ts +6 -0
  179. package/src/types/global.ts +26 -0
  180. package/src/types/index.ts +53 -0
  181. package/src/types/process.env.d.ts +56 -0
  182. package/src/userConfig.ts +6 -0
  183. package/src/utilities/__tests__/getErrorMessage.ts +32 -0
  184. package/src/utilities/__tests__/timeAgo.ts +46 -0
  185. package/src/utilities/checkVersion.ts +31 -0
  186. package/src/utilities/getErrorMessage.ts +30 -0
  187. package/src/utilities/index.ts +14 -0
  188. package/src/utilities/readRepoConfig.ts +22 -0
  189. package/src/utilities/readUserConfig.ts +24 -0
  190. package/src/utilities/synchronizeUserConfig.ts +26 -0
  191. package/src/utilities/timeAgo.ts +39 -0
  192. package/src/utilities/userLoggedIn.ts +28 -0
  193. package/src/utilities/writeRepoConfig.ts +11 -0
  194. package/src/utilities/writeUserConfig.ts +13 -0
  195. package/tsconfig.json +25 -0
@@ -0,0 +1,10 @@
1
+ /**
2
+ * All available payment platforms.
3
+ *
4
+ * @module
5
+ */
6
+
7
+ export {}
8
+ export * from './stripe/index.js'
9
+ export * from './google/index.js'
10
+ export * from './apple/index.js'
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Properties and methods for handling payments through Stripe.
3
+ *
4
+ * @module
5
+ */
6
+
7
+ import * as plans from './plans/index.js'
8
+ import * as types from '../../types.js'
9
+
10
+ /**
11
+ * The Stripe payment platform.
12
+ */
13
+ export const stripe: types.Platform<typeof plans> = {
14
+ /**
15
+ * An array of app platforms compatible with Stripe.
16
+ */
17
+ appPlatforms: [
18
+ undefined,
19
+ `mac`,
20
+ `windows`,
21
+ `linux`,
22
+ `cli`
23
+ ],
24
+
25
+ /**
26
+ * A map of Stripe plan keys to plan properties.
27
+ */
28
+ plans,
29
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Every available Stripe plan.
3
+ *
4
+ * @module
5
+ */
6
+
7
+ export * from './stripeBusinessMolecule.js'
8
+ export * from './stripeMonthly.js'
9
+ export * from './stripeMonthlyMolecule.js'
10
+ export * from './stripeSingleUseMolecule.js'
11
+ export * from './stripeUnlimitedUseMolecule.js'
12
+ export * from './stripeYearly.js'
@@ -0,0 +1,23 @@
1
+ import { Plan } from '../../../types.js'
2
+
3
+ /**
4
+ * The business Stripe plan for molecules.
5
+ */
6
+ export const stripeBusinessMolecule: Plan = {
7
+ planKey: `stripeBusinessMolecule`,
8
+ platformKey: `stripe`,
9
+ platformProductId: ``,
10
+ alias: `businessMolecule`,
11
+ period: ``,
12
+ price: `$449`,
13
+ allowMultiple: true,
14
+ minimumQuantity: 10,
15
+ autoRenews: false,
16
+ title: `Business Molecule`,
17
+ description: `Includes all of the core functionality available for full-stack applications.`,
18
+ capabilities: {
19
+ forMolecules: true,
20
+ premium: true,
21
+ attachments: true,
22
+ }
23
+ }
@@ -0,0 +1,20 @@
1
+ import { Plan } from '../../../types.js'
2
+
3
+ /**
4
+ * The monthly Stripe plan.
5
+ */
6
+ export const stripeMonthly: Plan = {
7
+ planKey: `stripeMonthly`,
8
+ platformKey: `stripe`,
9
+ platformProductId: ``,
10
+ alias: `monthly`,
11
+ period: `month`,
12
+ price: `$5`,
13
+ autoRenews: true,
14
+ title: `Monthly`,
15
+ description: `Create and view attachments.`,
16
+ capabilities: {
17
+ forUsers: true,
18
+ attachments: true,
19
+ }
20
+ }
@@ -0,0 +1,20 @@
1
+ import { Plan } from '../../../types.js'
2
+
3
+ /**
4
+ * The monthly Stripe plan for molecules.
5
+ */
6
+ export const stripeMonthlyMolecule: Plan = {
7
+ planKey: `stripeMonthlyMolecule`,
8
+ platformKey: `stripe`,
9
+ platformProductId: ``,
10
+ alias: `monthlyMolecule`,
11
+ period: `month`,
12
+ price: `$19`,
13
+ autoRenews: true,
14
+ title: `Monthly Molecule`,
15
+ description: `Includes all of the core functionality you've selected for your full-stack application.`,
16
+ capabilities: {
17
+ forMolecules: true,
18
+ attachments: true,
19
+ }
20
+ }
@@ -0,0 +1,21 @@
1
+ import { Plan } from '../../../types.js'
2
+
3
+ /**
4
+ * The single use Stripe plan for molecules.
5
+ */
6
+ export const stripeSingleUseMolecule: Plan = {
7
+ planKey: `stripeSingleUseMolecule`,
8
+ platformKey: `stripe`,
9
+ platformProductId: ``,
10
+ alias: `singleUseMolecule`,
11
+ period: ``,
12
+ price: `$499`,
13
+ autoRenews: false,
14
+ title: `Single Use Molecule`,
15
+ description: `Includes all of the core functionality you've selected for your full-stack application.`,
16
+ capabilities: {
17
+ forMolecules: true,
18
+ premium: true,
19
+ attachments: true,
20
+ }
21
+ }
@@ -0,0 +1,21 @@
1
+ import { Plan } from '../../../types.js'
2
+
3
+ /**
4
+ * The unlimited use Stripe plan for molecules.
5
+ */
6
+ export const stripeUnlimitedUseMolecule: Plan = {
7
+ planKey: `stripeUnlimitedUseMolecule`,
8
+ platformKey: `stripe`,
9
+ platformProductId: ``,
10
+ alias: `unlimitedUseMolecule`,
11
+ period: ``,
12
+ price: `$1499`,
13
+ autoRenews: false,
14
+ title: `Unlimited Use Molecule`,
15
+ description: `Includes all of the core functionality you've selected for your full-stack application.`,
16
+ capabilities: {
17
+ forMolecules: true,
18
+ premium: true,
19
+ attachments: true,
20
+ }
21
+ }
@@ -0,0 +1,21 @@
1
+ import { Plan } from '../../../types.js'
2
+
3
+ /**
4
+ * The yearly Stripe plan.
5
+ */
6
+ export const stripeYearly: Plan = {
7
+ planKey: `stripeYearly`,
8
+ platformKey: `stripe`,
9
+ platformProductId: ``,
10
+ alias: `yearly`,
11
+ period: `year`,
12
+ price: `$55`,
13
+ autoRenews: true,
14
+ title: `Yearly`,
15
+ description: `Create and view attachments.`,
16
+ highlightedDescription: `Get one month free, every year.`,
17
+ capabilities: {
18
+ forUsers: true,
19
+ attachments: true,
20
+ }
21
+ }
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Payment type definitions.
3
+ *
4
+ * @module
5
+ */
6
+
7
+ import * as resourceTypes from '../types'
8
+ import * as platforms from './platforms'
9
+
10
+ /**
11
+ * Every available platform.
12
+ */
13
+ export type PlatformKey = `` | keyof typeof platforms
14
+
15
+ /**
16
+ * Every available plan key.
17
+ */
18
+ export type PlanKey = ``
19
+ | keyof typeof platforms.stripe.plans
20
+ | keyof typeof platforms.apple.plans
21
+ | keyof typeof platforms.google.plans
22
+
23
+ /**
24
+ * Every available plan alias.
25
+ */
26
+ export type PlanAlias = ``
27
+ | `monthly`
28
+ | `yearly`
29
+ | `monthlyMolecule`
30
+ | `singleUseMolecule`
31
+ | `unlimitedUseMolecule`
32
+ | `businessMolecule`
33
+
34
+ /**
35
+ * Every available plan period.
36
+ */
37
+ export type PlanPeriod = ``
38
+ | `month`
39
+ | `year`
40
+
41
+ /**
42
+ * Available platforms.
43
+ */
44
+ export type PlanPlatform = `` | `stripe` | `apple` | `google`
45
+
46
+ /**
47
+ * Map of all available plans by unique keys.
48
+ */
49
+ export type Plans = { [planKey in PlanKey]: Plan }
50
+
51
+ /**
52
+ * Map of plan aliases to available plans, which may vary depending on platform and/or user.
53
+ */
54
+ export type PlansByAlias = { [alias in PlanAlias]?: Plan }
55
+
56
+ /**
57
+ * The payment's properties to be stored in the database.
58
+ */
59
+ export interface Props extends resourceTypes.Props {
60
+ /**
61
+ * The payment owner's `userId`.
62
+ */
63
+ userId: string
64
+ /**
65
+ * The payment's associated `moleculeId`, if any.
66
+ */
67
+ moleculeId?: string
68
+ /**
69
+ * The platform through which the product was purchased.
70
+ */
71
+ platformKey: PlatformKey
72
+ /**
73
+ * The transaction ID returned by the platform.
74
+ */
75
+ transactionId?: string
76
+ /**
77
+ * The purchased product ID.
78
+ *
79
+ * Possibly varies for each platform.
80
+ */
81
+ productId: string
82
+ /**
83
+ * Information describing things like session IDs, confirmations, purchase dates, renewal dates and expiration dates.
84
+ *
85
+ * Varies for each platform.
86
+ */
87
+ data?: JSONObject
88
+ /**
89
+ * The `transaction.appStoreReceipt` (from Apple) or the `transaction.purchaseToken` (from Google).
90
+ */
91
+ receipt?: string
92
+ }
93
+
94
+ /**
95
+ * Properties and methods used for managing purchases for some platform.
96
+ */
97
+ export interface Platform<Plans extends Record<string, Plan> = Record<string, Plan>> {
98
+ /**
99
+ * An array of app platforms the payment platform is compatible with.
100
+ */
101
+ appPlatforms?: Array<
102
+ undefined
103
+ | `ios`
104
+ | `android`
105
+ | `mac`
106
+ | `windows`
107
+ | `linux`
108
+ | `cli`
109
+ >
110
+ /**
111
+ * A map of unique plan keys to plans.
112
+ */
113
+ plans: Plans
114
+ }
115
+
116
+ /**
117
+ * A plan's properties, used for determining renewals and user restrictions.
118
+ *
119
+ * You will probably need to customize this.
120
+ */
121
+ export interface Plan {
122
+ /**
123
+ * The unique key used for this plan.
124
+ */
125
+ planKey: PlanKey
126
+ /**
127
+ * The platform the plan is for.
128
+ */
129
+ platformKey: PlatformKey
130
+ /**
131
+ * The platform product ID.
132
+ *
133
+ * Likely varies for each platform.
134
+ */
135
+ platformProductId: string
136
+ /**
137
+ * The plan's alias, typically the same for each platform.
138
+ */
139
+ alias: PlanAlias
140
+ /**
141
+ * How long the plan will be active.
142
+ */
143
+ period: PlanPeriod
144
+ /**
145
+ * `true` if the user is still in their free trial period.
146
+ */
147
+ inTrialPeriod?: boolean
148
+ /**
149
+ * The plan's price as a string with the currency - e.g., '$5'.
150
+ */
151
+ price: string
152
+ /**
153
+ * `true` if more than one can be purchased at a time.
154
+ */
155
+ allowMultiple?: boolean
156
+ /**
157
+ * A minimum quantity if more than one can be purchased.
158
+ */
159
+ minimumQuantity?: number
160
+ /**
161
+ * `true` if the plan will automatically renew.
162
+ */
163
+ autoRenews?: boolean
164
+ /**
165
+ * The plan title.
166
+ */
167
+ title: string
168
+ /**
169
+ * The plan description.
170
+ */
171
+ description: string
172
+ /**
173
+ * An optional short plan description.
174
+ */
175
+ shortDescription?: string
176
+ /**
177
+ * An optional highlighted bit of text about the plan.
178
+ */
179
+ highlightedDescription?: string
180
+ /**
181
+ * The features enabled by the plan.
182
+ */
183
+ capabilities: {
184
+ /**
185
+ * `true` if the plan is for users.
186
+ */
187
+ forUsers?: boolean
188
+ /**
189
+ * `true` if the plan is for molecules.
190
+ */
191
+ forMolecules?: boolean
192
+ /**
193
+ * Allows the user to access premium (private) repositories.
194
+ */
195
+ premium?: boolean
196
+ /**
197
+ * Allows the user to create and view attachments.
198
+ */
199
+ attachments?: boolean
200
+ }
201
+ }
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Resource type definitions.
3
+ *
4
+ * @module
5
+ */
6
+
7
+ // Internal reference for easier default type arguments within this module.
8
+ type ResourceProps = Props
9
+
10
+ /**
11
+ * The resource's properties.
12
+ */
13
+ export interface Props {
14
+ /**
15
+ * Usually a UUID.
16
+ */
17
+ id: string
18
+ /**
19
+ * When the resource was created.
20
+ *
21
+ * Usually an ISO 8601 timestamp.
22
+ */
23
+ createdAt: string
24
+ /**
25
+ * When the resource was last updated.
26
+ *
27
+ * Usually an ISO 8601 timestamp.
28
+ */
29
+ updatedAt: string
30
+ }
31
+
32
+ /**
33
+ * The successful resource response.
34
+ */
35
+ export interface SuccessResponse<Props = ResourceProps> {
36
+ /**
37
+ * HTTP status code.
38
+ */
39
+ statusCode: 200 | 201
40
+ /**
41
+ * The response body.
42
+ */
43
+ data: {
44
+ /**
45
+ * The resource's props.
46
+ */
47
+ props: Props
48
+ }
49
+ }
50
+
51
+ /**
52
+ * The successful resource response returning partial props.
53
+ */
54
+ export interface SuccessPartialResponse<Props = ResourceProps> {
55
+ /**
56
+ * HTTP status code.
57
+ */
58
+ statusCode: 200 | 201
59
+ /**
60
+ * The response body.
61
+ */
62
+ data: {
63
+ /**
64
+ * The resource's partial props.
65
+ */
66
+ props: Partial<Props>
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Options used when querying resources.
72
+ */
73
+ export interface QueryOptions {
74
+ /**
75
+ * Usually derived from a URL like '/messages?before[updatedAt]=2021-01-01T00:00:00.000Z'.
76
+ */
77
+ before: {
78
+ createdAt?: string
79
+ updatedAt?: string
80
+ }
81
+ /**
82
+ * Usually derived from a URL like '/messages?after[updatedAt]=2021-01-01T00:00:00.000Z'.
83
+ */
84
+ after: {
85
+ createdAt?: string
86
+ updatedAt?: string
87
+ }
88
+ /**
89
+ * You should limit this to indexed property keys.
90
+ *
91
+ * Usually derived from a URL like '/messages?orderBy=updatedAt'.
92
+ *
93
+ * @default updatedAt
94
+ */
95
+ orderBy: `createdAt` | `updatedAt`
96
+ /**
97
+ * Usually derived from a URL like '/messages?orderDirection=updatedAt'.
98
+ *
99
+ * @default desc
100
+ */
101
+ orderDirection: 'desc' | 'asc'
102
+ /**
103
+ * Usually derived from a URL like '/messages?limit=100'.
104
+ *
105
+ * @default 100
106
+ */
107
+ limit: number
108
+ }
109
+
110
+ /**
111
+ * The response when querying resources.
112
+ */
113
+ export interface QueryResponse<Props = ResourceProps> {
114
+ /**
115
+ * HTTP status code.
116
+ */
117
+ statusCode: 200
118
+ /**
119
+ * The response body containing the query results.
120
+ */
121
+ data: Props[]
122
+ }
123
+
124
+ /**
125
+ * Generic response with an optional body.
126
+ */
127
+ export interface GenericResponse {
128
+ /**
129
+ * HTTP status code.
130
+ */
131
+ statusCode: number
132
+ /**
133
+ * The optional response body.
134
+ */
135
+ data?: JSONValue
136
+ }
137
+
138
+ /**
139
+ * The response containing a message.
140
+ */
141
+ export interface MessageResponse {
142
+ /**
143
+ * HTTP status code.
144
+ */
145
+ statusCode: number
146
+ /**
147
+ * The response body.
148
+ */
149
+ data: {
150
+ /**
151
+ * The message.
152
+ */
153
+ message: string
154
+ }
155
+ }
156
+
157
+ /**
158
+ * The response when an error has occurred when handling a resource request.
159
+ */
160
+ export interface ErrorResponse {
161
+ /**
162
+ * HTTP status code.
163
+ */
164
+ statusCode: number
165
+ /**
166
+ * The response body containing an error message.
167
+ */
168
+ data: { error: string }
169
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The user API resource.
3
+ *
4
+ * @module
5
+ */
6
+
7
+ import { client } from '../../client.js'
8
+ import * as authorization from '../../authorization.js'
9
+ import * as types from './types.js'
10
+
11
+ export * as utilities from './utilities/index.js'
12
+ export * as types from './types.js'
13
+
14
+ export const logInCLI = ({
15
+ token,
16
+ deviceIds,
17
+ deviceName
18
+ }: types.LogInCLIProps): Promise<types.LogInCLIResponse> => (
19
+ client.post(`users/log-in/cli`, { token, deviceIds, deviceName })
20
+ )
21
+
22
+ export const logOut = async (): Promise<null> => {
23
+ authorization.removeHeader()
24
+ return null
25
+ }
26
+
27
+ export const read = (id: string): Promise<types.SuccessResponse> => (
28
+ client.get(`users/${id}`)
29
+ )