@api-client/core 0.19.16 → 0.19.18

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 (203) hide show
  1. package/build/src/browser.d.ts +12 -12
  2. package/build/src/browser.d.ts.map +1 -1
  3. package/build/src/browser.js +3 -3
  4. package/build/src/browser.js.map +1 -1
  5. package/build/src/exceptions/exception.d.ts +56 -0
  6. package/build/src/exceptions/exception.d.ts.map +1 -1
  7. package/build/src/exceptions/exception.js +111 -14
  8. package/build/src/exceptions/exception.js.map +1 -1
  9. package/build/src/index.d.ts +12 -12
  10. package/build/src/index.d.ts.map +1 -1
  11. package/build/src/index.js +3 -3
  12. package/build/src/index.js.map +1 -1
  13. package/build/src/mocking/ProjectMock.d.ts +1 -1
  14. package/build/src/mocking/ProjectMock.d.ts.map +1 -1
  15. package/build/src/mocking/ProjectMock.js.map +1 -1
  16. package/build/src/mocking/lib/File.d.ts +5 -5
  17. package/build/src/mocking/lib/File.d.ts.map +1 -1
  18. package/build/src/mocking/lib/File.js.map +1 -1
  19. package/build/src/mocking/lib/Organization.d.ts +3 -3
  20. package/build/src/mocking/lib/Organization.d.ts.map +1 -1
  21. package/build/src/mocking/lib/Organization.js +2 -1
  22. package/build/src/mocking/lib/Organization.js.map +1 -1
  23. package/build/src/mocking/lib/Permission.d.ts +6 -6
  24. package/build/src/mocking/lib/Permission.d.ts.map +1 -1
  25. package/build/src/mocking/lib/Permission.js.map +1 -1
  26. package/build/src/mocking/lib/User.d.ts +8 -4
  27. package/build/src/mocking/lib/User.d.ts.map +1 -1
  28. package/build/src/mocking/lib/User.js.map +1 -1
  29. package/build/src/modeling/ApiFile.d.ts +8 -4
  30. package/build/src/modeling/ApiFile.d.ts.map +1 -1
  31. package/build/src/modeling/ApiFile.js.map +1 -1
  32. package/build/src/modeling/ApiModel.d.ts +2 -2
  33. package/build/src/modeling/ApiModel.d.ts.map +1 -1
  34. package/build/src/modeling/ApiModel.js.map +1 -1
  35. package/build/src/modeling/DataDomain.d.ts +2 -2
  36. package/build/src/modeling/DataDomain.d.ts.map +1 -1
  37. package/build/src/modeling/DataDomain.js.map +1 -1
  38. package/build/src/modeling/DomainAssociation.d.ts +2 -2
  39. package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
  40. package/build/src/modeling/DomainAssociation.js.map +1 -1
  41. package/build/src/modeling/DomainEntity.d.ts +2 -2
  42. package/build/src/modeling/DomainEntity.d.ts.map +1 -1
  43. package/build/src/modeling/DomainEntity.js.map +1 -1
  44. package/build/src/modeling/DomainFile.d.ts +8 -4
  45. package/build/src/modeling/DomainFile.d.ts.map +1 -1
  46. package/build/src/modeling/DomainFile.js.map +1 -1
  47. package/build/src/modeling/DomainModel.d.ts +2 -2
  48. package/build/src/modeling/DomainModel.d.ts.map +1 -1
  49. package/build/src/modeling/DomainModel.js.map +1 -1
  50. package/build/src/modeling/DomainNamespace.d.ts +2 -2
  51. package/build/src/modeling/DomainNamespace.d.ts.map +1 -1
  52. package/build/src/modeling/DomainNamespace.js.map +1 -1
  53. package/build/src/modeling/DomainProperty.d.ts +2 -2
  54. package/build/src/modeling/DomainProperty.d.ts.map +1 -1
  55. package/build/src/modeling/DomainProperty.js.map +1 -1
  56. package/build/src/modeling/helpers/Intelisense.d.ts +38 -38
  57. package/build/src/modeling/helpers/Intelisense.d.ts.map +1 -1
  58. package/build/src/modeling/helpers/Intelisense.js.map +1 -1
  59. package/build/src/models/AiMessage.d.ts +3 -3
  60. package/build/src/models/AiMessage.d.ts.map +1 -1
  61. package/build/src/models/AiMessage.js.map +1 -1
  62. package/build/src/models/AiSession.d.ts +3 -3
  63. package/build/src/models/AiSession.d.ts.map +1 -1
  64. package/build/src/models/AiSession.js.map +1 -1
  65. package/build/src/models/CertificateFile.d.ts +2 -2
  66. package/build/src/models/CertificateFile.d.ts.map +1 -1
  67. package/build/src/models/CertificateFile.js.map +1 -1
  68. package/build/src/models/Environment.d.ts +2 -2
  69. package/build/src/models/Environment.d.ts.map +1 -1
  70. package/build/src/models/Environment.js.map +1 -1
  71. package/build/src/models/Folder.d.ts +9 -5
  72. package/build/src/models/Folder.d.ts.map +1 -1
  73. package/build/src/models/Folder.js.map +1 -1
  74. package/build/src/models/HttpProject.d.ts +2 -2
  75. package/build/src/models/HttpProject.d.ts.map +1 -1
  76. package/build/src/models/HttpProject.js.map +1 -1
  77. package/build/src/models/ProjectFolder.d.ts +2 -2
  78. package/build/src/models/ProjectFolder.d.ts.map +1 -1
  79. package/build/src/models/ProjectFolder.js.map +1 -1
  80. package/build/src/models/Request.d.ts +3 -3
  81. package/build/src/models/Request.d.ts.map +1 -1
  82. package/build/src/models/Request.js.map +1 -1
  83. package/build/src/models/Thing.d.ts +9 -5
  84. package/build/src/models/Thing.d.ts.map +1 -1
  85. package/build/src/models/Thing.js.map +1 -1
  86. package/build/src/models/TrashEntry.d.ts +2 -2
  87. package/build/src/models/TrashEntry.d.ts.map +1 -1
  88. package/build/src/models/TrashEntry.js.map +1 -1
  89. package/build/src/models/store/Capabilities.d.ts +5 -1
  90. package/build/src/models/store/Capabilities.d.ts.map +1 -1
  91. package/build/src/models/store/Capabilities.js.map +1 -1
  92. package/build/src/models/store/Deletion.d.ts +5 -1
  93. package/build/src/models/store/Deletion.d.ts.map +1 -1
  94. package/build/src/models/store/Deletion.js.map +1 -1
  95. package/build/src/models/store/File.d.ts +45 -37
  96. package/build/src/models/store/File.d.ts.map +1 -1
  97. package/build/src/models/store/File.js +1 -1
  98. package/build/src/models/store/File.js.map +1 -1
  99. package/build/src/models/store/Group.d.ts +3 -3
  100. package/build/src/models/store/Group.d.ts.map +1 -1
  101. package/build/src/models/store/Group.js.map +1 -1
  102. package/build/src/models/store/Invitation.d.ts +3 -3
  103. package/build/src/models/store/Invitation.d.ts.map +1 -1
  104. package/build/src/models/store/Invitation.js.map +1 -1
  105. package/build/src/models/store/Modification.d.ts +5 -1
  106. package/build/src/models/store/Modification.d.ts.map +1 -1
  107. package/build/src/models/store/Modification.js.map +1 -1
  108. package/build/src/models/store/Organization.d.ts +18 -13
  109. package/build/src/models/store/Organization.d.ts.map +1 -1
  110. package/build/src/models/store/Organization.js +29 -47
  111. package/build/src/models/store/Organization.js.map +1 -1
  112. package/build/src/models/store/Permission.d.ts +9 -5
  113. package/build/src/models/store/Permission.d.ts.map +1 -1
  114. package/build/src/models/store/Permission.js.map +1 -1
  115. package/build/src/models/store/User.d.ts +18 -6
  116. package/build/src/models/store/User.d.ts.map +1 -1
  117. package/build/src/models/store/User.js.map +1 -1
  118. package/build/src/models/store/UserIdentity.d.ts +9 -5
  119. package/build/src/models/store/UserIdentity.d.ts.map +1 -1
  120. package/build/src/models/store/UserIdentity.js.map +1 -1
  121. package/build/src/sdk/FilesSdk.d.ts +15 -15
  122. package/build/src/sdk/FilesSdk.d.ts.map +1 -1
  123. package/build/src/sdk/FilesSdk.js +1 -1
  124. package/build/src/sdk/FilesSdk.js.map +1 -1
  125. package/build/src/sdk/OrganizationsSdk.d.ts +9 -9
  126. package/build/src/sdk/OrganizationsSdk.d.ts.map +1 -1
  127. package/build/src/sdk/OrganizationsSdk.js.map +1 -1
  128. package/build/src/sdk/SdkMock.js +6 -6
  129. package/build/src/sdk/SdkMock.js.map +1 -1
  130. package/build/src/sdk/SharedSdk.d.ts +2 -2
  131. package/build/src/sdk/SharedSdk.d.ts.map +1 -1
  132. package/build/src/sdk/SharedSdk.js.map +1 -1
  133. package/build/src/sdk/StoreSdkNode.d.ts +1 -1
  134. package/build/src/sdk/StoreSdkNode.d.ts.map +1 -1
  135. package/build/src/sdk/StoreSdkNode.js.map +1 -1
  136. package/build/src/sdk/StoreSdkWeb.d.ts +1 -1
  137. package/build/src/sdk/StoreSdkWeb.d.ts.map +1 -1
  138. package/build/src/sdk/StoreSdkWeb.js.map +1 -1
  139. package/build/src/sdk/UsersSdk.d.ts +5 -5
  140. package/build/src/sdk/UsersSdk.d.ts.map +1 -1
  141. package/build/src/sdk/UsersSdk.js.map +1 -1
  142. package/build/tsconfig.tsbuildinfo +1 -1
  143. package/package.json +1 -1
  144. package/src/exceptions/exception.ts +119 -15
  145. package/src/mocking/ProjectMock.ts +1 -1
  146. package/src/mocking/lib/File.ts +5 -5
  147. package/src/mocking/lib/Organization.ts +5 -3
  148. package/src/mocking/lib/Permission.ts +8 -8
  149. package/src/mocking/lib/User.ts +11 -6
  150. package/src/modeling/ApiFile.ts +11 -6
  151. package/src/modeling/ApiModel.ts +2 -2
  152. package/src/modeling/DataDomain.ts +2 -2
  153. package/src/modeling/DomainAssociation.ts +2 -2
  154. package/src/modeling/DomainEntity.ts +2 -2
  155. package/src/modeling/DomainFile.ts +11 -6
  156. package/src/modeling/DomainModel.ts +2 -2
  157. package/src/modeling/DomainNamespace.ts +2 -2
  158. package/src/modeling/DomainProperty.ts +2 -2
  159. package/src/modeling/helpers/Intelisense.ts +41 -38
  160. package/src/models/AiMessage.ts +3 -3
  161. package/src/models/AiSession.ts +3 -3
  162. package/src/models/CertificateFile.ts +2 -2
  163. package/src/models/Environment.ts +2 -2
  164. package/src/models/Folder.ts +13 -8
  165. package/src/models/HttpProject.ts +2 -2
  166. package/src/models/ProjectFolder.ts +2 -2
  167. package/src/models/Request.ts +3 -3
  168. package/src/models/Thing.ts +14 -9
  169. package/src/models/TrashEntry.ts +2 -2
  170. package/src/models/store/Capabilities.ts +6 -1
  171. package/src/models/store/Deletion.ts +6 -1
  172. package/src/models/store/File.ts +53 -43
  173. package/src/models/store/Group.ts +3 -3
  174. package/src/models/store/Invitation.ts +3 -3
  175. package/src/models/store/Modification.ts +6 -1
  176. package/src/models/store/Organization.ts +45 -60
  177. package/src/models/store/Permission.ts +17 -12
  178. package/src/models/store/User.ts +21 -6
  179. package/src/models/store/UserIdentity.ts +13 -8
  180. package/src/sdk/FilesSdk.ts +29 -25
  181. package/src/sdk/OrganizationsSdk.ts +20 -16
  182. package/src/sdk/SdkMock.ts +16 -16
  183. package/src/sdk/SharedSdk.ts +3 -3
  184. package/src/sdk/StoreSdkNode.ts +3 -3
  185. package/src/sdk/StoreSdkWeb.ts +3 -3
  186. package/src/sdk/UsersSdk.ts +6 -6
  187. package/tests/unit/exceptions/exception.spec.ts +261 -0
  188. package/tests/unit/mocking/current/File.spec.ts +5 -5
  189. package/tests/unit/mocking/current/Organization.spec.ts +4 -3
  190. package/tests/unit/mocking/current/Permission.spec.ts +2 -2
  191. package/tests/unit/mocking/current/User.spec.ts +2 -2
  192. package/tests/unit/modeling/domain_file.spec.ts +3 -3
  193. package/tests/unit/models/File/createFileCapabilities.spec.ts +3 -3
  194. package/tests/unit/models/File/new.spec.ts +2 -2
  195. package/tests/unit/models/File/setDeleted.spec.ts +3 -3
  196. package/tests/unit/models/File/setLastModified.spec.ts +3 -3
  197. package/tests/unit/models/File/toJSON.spec.ts +2 -2
  198. package/tests/unit/models/Folder/create.spec.ts +3 -3
  199. package/tests/unit/models/Permission/all.spec.ts +3 -3
  200. package/tests/unit/models/store/Invitation.spec.ts +2 -2
  201. package/tests/unit/models/store/Organization.spec.ts +100 -0
  202. package/tests/unit/models/store/Permission.spec.ts +16 -6
  203. package/tests/unit/models/thing.spec.ts +3 -3
@@ -7,7 +7,7 @@ import {
7
7
  SdkOptions,
8
8
  } from './SdkBase.js'
9
9
  import { RouteBuilder } from './RouteBuilder.js'
10
- import { IUser } from '../models/store/User.js'
10
+ import { UserSchema } from '../models/store/User.js'
11
11
  import { Exception } from '../exceptions/exception.js'
12
12
 
13
13
  export interface IJwtInfo {
@@ -51,7 +51,7 @@ export interface IJwtUser {
51
51
  hd?: string
52
52
  }
53
53
 
54
- export interface IRegistrationInfo {
54
+ export interface RegistrationInfoSchema {
55
55
  reason: 'new-organization' | 'existing-organization'
56
56
  /**
57
57
  * The decoded JWT user information.
@@ -60,7 +60,7 @@ export interface IRegistrationInfo {
60
60
  user: IJwtInfo
61
61
  }
62
62
 
63
- export interface IOrganizationRegistrationInfo extends IRegistrationInfo {
63
+ export interface OrganizationRegistrationInfoSchema extends RegistrationInfoSchema {
64
64
  reason: 'new-organization'
65
65
  /**
66
66
  * The name of the organization to create for the user.
@@ -68,7 +68,7 @@ export interface IOrganizationRegistrationInfo extends IRegistrationInfo {
68
68
  organizationName: string
69
69
  }
70
70
 
71
- export interface IOrganizationAddUserInfo extends IRegistrationInfo {
71
+ export interface OrganizationAddUserInfoSchema extends RegistrationInfoSchema {
72
72
  reason: 'existing-organization'
73
73
  /**
74
74
  * Set when adding a user to an existing organization.
@@ -85,7 +85,7 @@ export class UsersSdk extends SdkBase {
85
85
  * Reads the current user.
86
86
  * @param request Optional request options.
87
87
  */
88
- async me(request: SdkOptions = {}): Promise<IUser> {
88
+ async me(request: SdkOptions = {}): Promise<UserSchema> {
89
89
  const { token } = request
90
90
  const url = this.sdk.getUrl(RouteBuilder.usersMe())
91
91
  const result = await this.sdk.http.get(url.toString(), { token })
@@ -98,7 +98,7 @@ export class UsersSdk extends SdkBase {
98
98
  if (!result.body) {
99
99
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
100
100
  }
101
- let data: IUser
101
+ let data: UserSchema
102
102
  try {
103
103
  data = JSON.parse(result.body)
104
104
  } catch {
@@ -0,0 +1,261 @@
1
+ import { test } from '@japa/runner'
2
+ import { Exception, fromError } from '../../../src/exceptions/exception.js'
3
+
4
+ test.group('Exceptions > Exception', () => {
5
+ test('constructor sets basic properties', ({ assert }) => {
6
+ const ex = new Exception('Test message', { code: 'E_TEST', status: 400, help: 'Help me' })
7
+ assert.equal(ex.message, 'Test message')
8
+ assert.equal(ex.code, 'E_TEST')
9
+ assert.equal(ex.status, 400)
10
+ assert.equal(ex.help, 'Help me')
11
+ assert.equal(ex.name, 'Exception')
12
+ })
13
+
14
+ test('constructor uses static defaults', ({ assert }) => {
15
+ class CustomException extends Exception {
16
+ static override message = 'Static message'
17
+ static override code = 'E_STATIC'
18
+ static override status = 404
19
+ static override help = 'Static help'
20
+ }
21
+ const ex = new CustomException()
22
+ assert.equal(ex.message, 'Static message')
23
+ assert.equal(ex.code, 'E_STATIC')
24
+ assert.equal(ex.status, 404)
25
+ assert.equal(ex.help, 'Static help')
26
+ assert.equal(ex.name, 'CustomException')
27
+ })
28
+
29
+ test('constructor defaults status to 500', ({ assert }) => {
30
+ const ex = new Exception('Test')
31
+ assert.equal(ex.status, 500)
32
+ })
33
+
34
+ test('constructor accepts status 0', ({ assert }) => {
35
+ const ex = new Exception('Test', { status: 0 })
36
+ assert.equal(ex.status, 0)
37
+ })
38
+
39
+ test('setters allow chaining and update properties', ({ assert }) => {
40
+ const ex = new Exception('Test')
41
+ const result = ex.setCode('E_CHAIN').setStatus(401).setHelp('Chained')
42
+
43
+ assert.strictEqual(result, ex)
44
+ assert.equal(ex.code, 'E_CHAIN')
45
+ assert.equal(ex.status, 401)
46
+ assert.equal(ex.help, 'Chained')
47
+ })
48
+
49
+ test('toString returns properly formatted string', ({ assert }) => {
50
+ const ex1 = new Exception('Error without code')
51
+ assert.equal(ex1.toString(), 'Exception: Error without code')
52
+
53
+ const ex2 = new Exception('Error with code', { code: 'E_CODE' })
54
+ assert.equal(ex2.toString(), 'Exception [E_CODE]: Error with code')
55
+ })
56
+
57
+ test('toStringTag returns class name', ({ assert }) => {
58
+ const ex = new Exception('Test')
59
+ assert.equal(Object.prototype.toString.call(ex), '[object Exception]')
60
+
61
+ class CustomTagError extends Exception {}
62
+ const ex2 = new CustomTagError('Test')
63
+ assert.equal(Object.prototype.toString.call(ex2), '[object CustomTagError]')
64
+ })
65
+
66
+ test('toJSON serializes properties', ({ assert }) => {
67
+ const ex = new Exception('Test message', { code: 'E_TEST', status: 400, help: 'Help me' })
68
+ const json = ex.toJSON()
69
+
70
+ assert.deepEqual(json, {
71
+ name: 'Exception',
72
+ message: 'Test message',
73
+ code: 'E_TEST',
74
+ status: 400,
75
+ help: 'Help me',
76
+ })
77
+ })
78
+
79
+ test('toJSON does not output unset optional properties', ({ assert }) => {
80
+ const ex = new Exception('Basic')
81
+ const json = ex.toJSON()
82
+
83
+ assert.deepEqual(json, {
84
+ name: 'Exception',
85
+ message: 'Basic',
86
+ status: 500,
87
+ })
88
+ })
89
+
90
+ test('fromRawException reconstructs exception', ({ assert }) => {
91
+ const raw = {
92
+ message: 'Raw message',
93
+ code: 'E_RAW',
94
+ status: '403',
95
+ help: 'Raw help',
96
+ name: 'RawName',
97
+ }
98
+ const ex = Exception.fromRawException(raw, 'Default')
99
+
100
+ assert.instanceOf(ex, Exception)
101
+ assert.equal(ex.message, 'Raw message')
102
+ assert.equal(ex.code, 'E_RAW')
103
+ assert.equal(ex.status, 403)
104
+ assert.equal(ex.help, 'Raw help')
105
+ assert.equal(ex.name, 'RawName')
106
+ })
107
+
108
+ test('fromRawException uses default message if missing', ({ assert }) => {
109
+ const ex = Exception.fromRawException({}, 'Fallback message')
110
+ assert.equal(ex.message, 'Fallback message')
111
+ })
112
+ })
113
+
114
+ test.group('Exceptions > Exception > fromError()', () => {
115
+ test('creates Exception from standard Error', ({ assert }) => {
116
+ const err = new Error('standard error message')
117
+ const ex = fromError(err)
118
+
119
+ assert.instanceOf(ex, Exception)
120
+ assert.equal(ex.message, 'standard error message')
121
+ })
122
+
123
+ test('creates Exception from Error with no message', ({ assert }) => {
124
+ const err = new Error()
125
+ const ex = fromError(err)
126
+
127
+ assert.instanceOf(ex, Exception)
128
+ assert.equal(ex.message, 'An error occurred')
129
+ })
130
+
131
+ test('copies code property', ({ assert }) => {
132
+ const err = new Error('test') as unknown as Exception
133
+ err.code = 'TEST_CODE'
134
+ const ex = fromError(err)
135
+
136
+ assert.equal(ex.code, 'TEST_CODE')
137
+ })
138
+
139
+ test('copies status property', ({ assert }) => {
140
+ const err = new Error('test') as unknown as Exception
141
+ err.status = 404
142
+ const ex = fromError(err)
143
+
144
+ assert.equal(ex.status, 404)
145
+ })
146
+
147
+ test('copies help property', ({ assert }) => {
148
+ const err = new Error('test') as unknown as Exception
149
+ err.help = 'Help text'
150
+ const ex = fromError(err)
151
+
152
+ assert.equal(ex.help, 'Help text')
153
+ })
154
+
155
+ test('copies name property', ({ assert }) => {
156
+ const err = new Error('test')
157
+ err.name = 'CustomErrorName'
158
+ const ex = fromError(err)
159
+
160
+ assert.equal(ex.name, 'CustomErrorName')
161
+ })
162
+
163
+ test('handles when object is already an Exception instance', ({ assert }) => {
164
+ const originalEx = new Exception('Original exception')
165
+ originalEx.code = 'ORIGINAL_CODE'
166
+ originalEx.status = 400
167
+ originalEx.setHelp('Original help')
168
+
169
+ const newEx = fromError(originalEx)
170
+
171
+ assert.instanceOf(newEx, Exception)
172
+ assert.equal(newEx.message, 'Original exception')
173
+ assert.equal(newEx.code, 'ORIGINAL_CODE')
174
+ assert.equal(newEx.status, 400)
175
+ assert.equal(newEx.help, 'Original help')
176
+ assert.equal(newEx.name, 'Exception')
177
+ })
178
+
179
+ test('uses default message when error has no message', ({ assert }) => {
180
+ const err = new Error()
181
+ err.message = ''
182
+ const ex = fromError(err, { message: 'Default message' })
183
+
184
+ assert.equal(ex.message, 'Default message')
185
+ })
186
+
187
+ test('error message takes precedence over default message', ({ assert }) => {
188
+ const err = new Error('Original message')
189
+ const ex = fromError(err, { message: 'Default message' })
190
+
191
+ assert.equal(ex.message, 'Original message')
192
+ })
193
+
194
+ test('uses default code when error has no code', ({ assert }) => {
195
+ const err = new Error('test')
196
+ const ex = fromError(err, { code: 'DEFAULT_CODE' })
197
+
198
+ assert.equal(ex.code, 'DEFAULT_CODE')
199
+ })
200
+
201
+ test('error code takes precedence over default code', ({ assert }) => {
202
+ const err = new Error('test') as unknown as Exception
203
+ err.code = 'ORIGINAL_CODE'
204
+ const ex = fromError(err, { code: 'DEFAULT_CODE' })
205
+
206
+ assert.equal(ex.code, 'ORIGINAL_CODE')
207
+ })
208
+
209
+ test('uses default status when error has no status', ({ assert }) => {
210
+ const err = new Error('test')
211
+ const ex = fromError(err, { status: 401 })
212
+
213
+ assert.equal(ex.status, 401)
214
+ })
215
+
216
+ test('uses default status when error status is invalid', ({ assert }) => {
217
+ const err = new Error('test') as unknown as Exception
218
+ err.status = 'invalid' as unknown as number
219
+ const ex = fromError(err, { status: 403 })
220
+
221
+ assert.equal(ex.status, 403)
222
+ })
223
+
224
+ test('error status takes precedence over default status', ({ assert }) => {
225
+ const err = new Error('test') as unknown as Exception
226
+ err.status = 404
227
+ const ex = fromError(err, { status: 401 })
228
+
229
+ assert.equal(ex.status, 404)
230
+ })
231
+
232
+ test('uses default help when error has no help', ({ assert }) => {
233
+ const err = new Error('test')
234
+ const ex = fromError(err, { help: 'Default help text' })
235
+
236
+ assert.equal(ex.help, 'Default help text')
237
+ })
238
+
239
+ test('error help takes precedence over default help', ({ assert }) => {
240
+ const err = new Error('test') as unknown as Exception
241
+ err.help = 'Original help text'
242
+ const ex = fromError(err, { help: 'Default help text' })
243
+
244
+ assert.equal(ex.help, 'Original help text')
245
+ })
246
+
247
+ test('uses default name when error has no name', ({ assert }) => {
248
+ const err = { message: 'test' } as unknown as Error
249
+ const ex = fromError(err, { name: 'DefaultName' })
250
+
251
+ assert.equal(ex.name, 'DefaultName')
252
+ })
253
+
254
+ test('error name takes precedence over default name', ({ assert }) => {
255
+ const err = new Error('test')
256
+ err.name = 'OriginalName'
257
+ const ex = fromError(err, { name: 'DefaultName' })
258
+
259
+ assert.equal(ex.name, 'OriginalName')
260
+ })
261
+ })
@@ -1,7 +1,7 @@
1
1
  import { test } from '@japa/runner'
2
2
  import { File } from '../../../../src/mocking/lib/File.js'
3
3
  import { FolderKind, ProjectKind } from '../../../../src/models/kinds.js'
4
- import type { IFile } from '../../../../src/models/store/File.js'
4
+ import type { FileSchema } from '../../../../src/models/store/File.js'
5
5
 
6
6
  test.group('File', (group) => {
7
7
  let fileMock: File
@@ -18,7 +18,7 @@ test.group('File', (group) => {
18
18
  })
19
19
 
20
20
  test('file(init) allows overriding properties', ({ assert }) => {
21
- const init: Partial<IFile> = {
21
+ const init: Partial<FileSchema> = {
22
22
  kind: ProjectKind,
23
23
  info: { name: 'My Project' },
24
24
  }
@@ -34,7 +34,7 @@ test.group('File', (group) => {
34
34
  })
35
35
 
36
36
  test('files(size, init) allows overriding properties', ({ assert }) => {
37
- const init: Partial<IFile> = {
37
+ const init: Partial<FileSchema> = {
38
38
  kind: ProjectKind,
39
39
  }
40
40
  const result = fileMock.files(3, init)
@@ -51,7 +51,7 @@ test.group('File', (group) => {
51
51
  })
52
52
 
53
53
  test('folder(init) allows overriding properties', ({ assert }) => {
54
- const init: Partial<IFile> = {
54
+ const init: Partial<FileSchema> = {
55
55
  key: 'custom-folder-key',
56
56
  }
57
57
  const result = fileMock.folder(init)
@@ -66,7 +66,7 @@ test.group('File', (group) => {
66
66
  })
67
67
 
68
68
  test('folders(size, init) allows overriding properties', ({ assert }) => {
69
- const init: Partial<IFile> = {
69
+ const init: Partial<FileSchema> = {
70
70
  key: 'batch-key',
71
71
  }
72
72
  const result = fileMock.folders(3, init)
@@ -1,7 +1,7 @@
1
1
  import { test } from '@japa/runner'
2
2
  import { Organization } from '../../../../src/mocking/lib/Organization.js'
3
3
  import { OrganizationKind } from '../../../../src/models/kinds.js'
4
- import type { IOrganization } from '../../../../src/models/store/Organization.js'
4
+ import type { OrganizationSchema } from '../../../../src/models/store/Organization.js'
5
5
 
6
6
  test.group('Organization', (group) => {
7
7
  let organization: Organization
@@ -19,10 +19,11 @@ test.group('Organization', (group) => {
19
19
  assert.property(result, 'createdBy')
20
20
  assert.property(result, 'createdDate')
21
21
  assert.property(result, 'grantType')
22
+ assert.property(result, 'slug')
22
23
  })
23
24
 
24
25
  test('organization(init) allows overriding properties', ({ assert }) => {
25
- const init: Partial<IOrganization> = {
26
+ const init: Partial<OrganizationSchema> = {
26
27
  key: 'custom-org-key',
27
28
  name: 'Custom Org',
28
29
  }
@@ -38,7 +39,7 @@ test.group('Organization', (group) => {
38
39
  })
39
40
 
40
41
  test('organizations(size, init) allows overriding properties', ({ assert }) => {
41
- const init: Partial<IOrganization> = {
42
+ const init: Partial<OrganizationSchema> = {
42
43
  name: 'Batch Org',
43
44
  }
44
45
  const result = organization.organizations(3, init)
@@ -1,7 +1,7 @@
1
1
  import { test } from '@japa/runner'
2
2
  import { Permission } from '../../../../src/mocking/lib/Permission.js'
3
3
  import { Kind as PermissionKind } from '../../../../src/models/store/Permission.js'
4
- import type { IPermission } from '../../../../src/models/store/Permission.js'
4
+ import type { PermissionSchema } from '../../../../src/models/store/Permission.js'
5
5
 
6
6
  test.group('permission()', (group) => {
7
7
  let permission: Permission
@@ -29,7 +29,7 @@ test.group('permission()', (group) => {
29
29
  ])
30
30
  .run(({ assert }, { property, type }) => {
31
31
  const result = permission.permission()
32
- assert.typeOf(result[property as keyof IPermission], type)
32
+ assert.typeOf(result[property as keyof PermissionSchema], type)
33
33
  })
34
34
 
35
35
  test('has the correct kind', ({ assert }) => {
@@ -1,7 +1,7 @@
1
1
  import { test } from '@japa/runner'
2
2
  import { User } from '../../../../src/mocking/lib/User.js'
3
3
  import { Kind as UserKind } from '../../../../src/models/store/User.js'
4
- import type { IUser } from '../../../../src/index.js'
4
+ import type { UserSchema } from '../../../../src/index.js'
5
5
 
6
6
  test.group('user()', (group) => {
7
7
  let user: User
@@ -25,7 +25,7 @@ test.group('user()', (group) => {
25
25
  ])
26
26
  .run(({ assert }, { property, type }) => {
27
27
  const result = user.user()
28
- assert.typeOf(result[property as keyof IUser], type)
28
+ assert.typeOf(result[property as keyof UserSchema], type)
29
29
  })
30
30
 
31
31
  test('has the kind', ({ assert }) => {
@@ -1,5 +1,5 @@
1
1
  import { test } from '@japa/runner'
2
- import { DomainFile, IDomainFile, ThingKind, DomainFileKind, DataDomain } from '../../../src/index.js'
2
+ import { DomainFile, type DomainFileSchema, ThingKind, DomainFileKind, DataDomain } from '../../../src/index.js'
3
3
 
4
4
  test.group('DomainFile.fromDataDomain()', () => {
5
5
  test('sets the kind', ({ assert }) => {
@@ -36,7 +36,7 @@ test.group('constructor()', () => {
36
36
  })
37
37
 
38
38
  test('creates a data file from the schema values', ({ assert }) => {
39
- const schema: IDomainFile = {
39
+ const schema: DomainFileSchema = {
40
40
  kind: DomainFileKind,
41
41
  info: {
42
42
  kind: ThingKind,
@@ -74,7 +74,7 @@ test.group('constructor()', () => {
74
74
  })
75
75
 
76
76
  test('creates a data file from the JSON schema string', ({ assert }) => {
77
- const schema: IDomainFile = {
77
+ const schema: DomainFileSchema = {
78
78
  kind: DomainFileKind,
79
79
  info: {
80
80
  kind: ThingKind,
@@ -1,5 +1,5 @@
1
1
  import { test } from '@japa/runner'
2
- import { File, Folder, ICapabilities, PermissionRole, Project } from '../../../../src/index.js'
2
+ import { File, Folder, CapabilitiesSchema, PermissionRole, Project } from '../../../../src/index.js'
3
3
 
4
4
  test.group('File.createFileCapabilities()', () => {
5
5
  test('{$i} correctly sets file capabilities')
@@ -68,7 +68,7 @@ test.group('File.createFileCapabilities()', () => {
68
68
  .run(({ assert }, row) => {
69
69
  const file = new Project()
70
70
  const result = File.createFileCapabilities(file, row[1] as PermissionRole)
71
- const key = row[0] as keyof ICapabilities
71
+ const key = row[0] as keyof CapabilitiesSchema
72
72
  assert.strictEqual(result[key], row[2])
73
73
  })
74
74
 
@@ -138,7 +138,7 @@ test.group('File.createFileCapabilities()', () => {
138
138
  .run(({ assert }, row) => {
139
139
  const file = new Folder()
140
140
  const result = File.createFileCapabilities(file, row[1] as PermissionRole)
141
- const key = row[0] as keyof ICapabilities
141
+ const key = row[0] as keyof CapabilitiesSchema
142
142
  assert.strictEqual(result[key], row[2])
143
143
  })
144
144
  })
@@ -1,9 +1,9 @@
1
1
  import { test } from '@japa/runner'
2
- import { File, ThingKind, IFile } from '../../../../src/index.js'
2
+ import { File, ThingKind, FileSchema } from '../../../../src/index.js'
3
3
 
4
4
  test.group('File.new()', (group) => {
5
5
  let file: File
6
- let base: IFile
6
+ let base: FileSchema
7
7
  group.each.setup(async () => {
8
8
  file = new File()
9
9
  base = {
@@ -1,8 +1,8 @@
1
1
  import { test } from '@japa/runner'
2
- import { File, IUser } from '../../../../src/index.js'
2
+ import { File, UserSchema } from '../../../../src/index.js'
3
3
 
4
4
  test.group('File.setDeleted()', () => {
5
- const user: IUser = {
5
+ const user: UserSchema = {
6
6
  key: '123',
7
7
  kind: 'Core#User',
8
8
  name: 'a1',
@@ -59,7 +59,7 @@ test.group('File.setDeleted()', () => {
59
59
  })
60
60
 
61
61
  test.group('File::setDeleted()', () => {
62
- const user: IUser = {
62
+ const user: UserSchema = {
63
63
  key: '123',
64
64
  kind: 'Core#User',
65
65
  name: 'a1',
@@ -1,8 +1,8 @@
1
1
  import { test } from '@japa/runner'
2
- import { File, IUser } from '../../../../src/index.js'
2
+ import { File, UserSchema } from '../../../../src/index.js'
3
3
 
4
4
  test.group('File.setLastModified()', () => {
5
- const user: IUser = {
5
+ const user: UserSchema = {
6
6
  key: '123',
7
7
  kind: 'Core#User',
8
8
  name: 'a1',
@@ -53,7 +53,7 @@ test.group('File.setLastModified()', () => {
53
53
  })
54
54
 
55
55
  test.group('File::setLastModified()', () => {
56
- const user: IUser = {
56
+ const user: UserSchema = {
57
57
  key: '123',
58
58
  kind: 'Core#User',
59
59
  name: 'a1',
@@ -1,9 +1,9 @@
1
1
  import { test } from '@japa/runner'
2
- import { File, ThingKind, IFile } from '../../../../src/index.js'
2
+ import { File, ThingKind, FileSchema } from '../../../../src/index.js'
3
3
 
4
4
  test.group('File.toJSON()', (group) => {
5
5
  let file: File
6
- let base: IFile
6
+ let base: FileSchema
7
7
 
8
8
  group.each.setup(() => {
9
9
  file = new File()
@@ -1,5 +1,5 @@
1
1
  import { test } from '@japa/runner'
2
- import { Folder, FolderKind, IFolder, ThingKind } from '../../../../src/index.js'
2
+ import { Folder, FolderKind, FolderSchema, ThingKind } from '../../../../src/index.js'
3
3
 
4
4
  test.group('Folder.fromName()', () => {
5
5
  test('sets the kind', ({ assert }) => {
@@ -22,7 +22,7 @@ test.group('Folder.constructor()', () => {
22
22
  })
23
23
 
24
24
  test('creates a Folder from the schema values', ({ assert }) => {
25
- const schema: IFolder = {
25
+ const schema: FolderSchema = {
26
26
  kind: FolderKind,
27
27
  info: {
28
28
  kind: ThingKind,
@@ -60,7 +60,7 @@ test.group('Folder.constructor()', () => {
60
60
  })
61
61
 
62
62
  test('creates a Folder from the JSON schema string', ({ assert }) => {
63
- const schema: IFolder = {
63
+ const schema: FolderSchema = {
64
64
  kind: FolderKind,
65
65
  info: {
66
66
  kind: ThingKind,
@@ -1,5 +1,5 @@
1
1
  import { test } from '@japa/runner'
2
- import { IPermission, Permission, PermissionKind, PermissionRole } from '../../../../src/index.js'
2
+ import { PermissionSchema, Permission, PermissionKind, PermissionRole } from '../../../../src/index.js'
3
3
 
4
4
  test.group('Permission', () => {
5
5
  test('creates a default Permission', ({ assert }) => {
@@ -16,7 +16,7 @@ test.group('Permission', () => {
16
16
  })
17
17
 
18
18
  test('creates permissions from the schema', ({ assert }) => {
19
- const schema: IPermission = {
19
+ const schema: PermissionSchema = {
20
20
  kind: PermissionKind,
21
21
  key: '1',
22
22
  addingUser: '2',
@@ -44,7 +44,7 @@ test.group('Permission', () => {
44
44
  })
45
45
 
46
46
  test('creates permissions from the JSON schema', ({ assert }) => {
47
- const schema: IPermission = {
47
+ const schema: PermissionSchema = {
48
48
  kind: PermissionKind,
49
49
  key: '1',
50
50
  addingUser: '2',
@@ -1,5 +1,5 @@
1
1
  import { test } from '@japa/runner'
2
- import { Invitation, InvitationKind, type InvitationSchema, type IDeletion } from '../../../../src/index.js'
2
+ import { Invitation, InvitationKind, type InvitationSchema, type DeletionSchema } from '../../../../src/index.js'
3
3
  import { OperationType } from '@api-client/json/patch/types.js'
4
4
 
5
5
  const baseInput: Partial<InvitationSchema> = {
@@ -56,7 +56,7 @@ test.group('Invitation', (group) => {
56
56
  })
57
57
 
58
58
  test('toJSON() serializes all properties correctly', ({ assert }) => {
59
- const deletionInfo: IDeletion = { time: Date.now(), user: 'deleter-id', byMe: false, name: 'Deleter' }
59
+ const deletionInfo: DeletionSchema = { time: Date.now(), user: 'deleter-id', byMe: false, name: 'Deleter' }
60
60
  const input: Partial<InvitationSchema> = {
61
61
  ...baseInput,
62
62
  key: 'inv-key-json',