@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.
- package/build/src/browser.d.ts +12 -12
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +3 -3
- package/build/src/browser.js.map +1 -1
- package/build/src/exceptions/exception.d.ts +56 -0
- package/build/src/exceptions/exception.d.ts.map +1 -1
- package/build/src/exceptions/exception.js +111 -14
- package/build/src/exceptions/exception.js.map +1 -1
- package/build/src/index.d.ts +12 -12
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +3 -3
- package/build/src/index.js.map +1 -1
- package/build/src/mocking/ProjectMock.d.ts +1 -1
- package/build/src/mocking/ProjectMock.d.ts.map +1 -1
- package/build/src/mocking/ProjectMock.js.map +1 -1
- package/build/src/mocking/lib/File.d.ts +5 -5
- package/build/src/mocking/lib/File.d.ts.map +1 -1
- package/build/src/mocking/lib/File.js.map +1 -1
- package/build/src/mocking/lib/Organization.d.ts +3 -3
- package/build/src/mocking/lib/Organization.d.ts.map +1 -1
- package/build/src/mocking/lib/Organization.js +2 -1
- package/build/src/mocking/lib/Organization.js.map +1 -1
- package/build/src/mocking/lib/Permission.d.ts +6 -6
- package/build/src/mocking/lib/Permission.d.ts.map +1 -1
- package/build/src/mocking/lib/Permission.js.map +1 -1
- package/build/src/mocking/lib/User.d.ts +8 -4
- package/build/src/mocking/lib/User.d.ts.map +1 -1
- package/build/src/mocking/lib/User.js.map +1 -1
- package/build/src/modeling/ApiFile.d.ts +8 -4
- package/build/src/modeling/ApiFile.d.ts.map +1 -1
- package/build/src/modeling/ApiFile.js.map +1 -1
- package/build/src/modeling/ApiModel.d.ts +2 -2
- package/build/src/modeling/ApiModel.d.ts.map +1 -1
- package/build/src/modeling/ApiModel.js.map +1 -1
- package/build/src/modeling/DataDomain.d.ts +2 -2
- package/build/src/modeling/DataDomain.d.ts.map +1 -1
- package/build/src/modeling/DataDomain.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +2 -2
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.d.ts +2 -2
- package/build/src/modeling/DomainEntity.d.ts.map +1 -1
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/DomainFile.d.ts +8 -4
- package/build/src/modeling/DomainFile.d.ts.map +1 -1
- package/build/src/modeling/DomainFile.js.map +1 -1
- package/build/src/modeling/DomainModel.d.ts +2 -2
- package/build/src/modeling/DomainModel.d.ts.map +1 -1
- package/build/src/modeling/DomainModel.js.map +1 -1
- package/build/src/modeling/DomainNamespace.d.ts +2 -2
- package/build/src/modeling/DomainNamespace.d.ts.map +1 -1
- package/build/src/modeling/DomainNamespace.js.map +1 -1
- package/build/src/modeling/DomainProperty.d.ts +2 -2
- package/build/src/modeling/DomainProperty.d.ts.map +1 -1
- package/build/src/modeling/DomainProperty.js.map +1 -1
- package/build/src/modeling/helpers/Intelisense.d.ts +38 -38
- package/build/src/modeling/helpers/Intelisense.d.ts.map +1 -1
- package/build/src/modeling/helpers/Intelisense.js.map +1 -1
- package/build/src/models/AiMessage.d.ts +3 -3
- package/build/src/models/AiMessage.d.ts.map +1 -1
- package/build/src/models/AiMessage.js.map +1 -1
- package/build/src/models/AiSession.d.ts +3 -3
- package/build/src/models/AiSession.d.ts.map +1 -1
- package/build/src/models/AiSession.js.map +1 -1
- package/build/src/models/CertificateFile.d.ts +2 -2
- package/build/src/models/CertificateFile.d.ts.map +1 -1
- package/build/src/models/CertificateFile.js.map +1 -1
- package/build/src/models/Environment.d.ts +2 -2
- package/build/src/models/Environment.d.ts.map +1 -1
- package/build/src/models/Environment.js.map +1 -1
- package/build/src/models/Folder.d.ts +9 -5
- package/build/src/models/Folder.d.ts.map +1 -1
- package/build/src/models/Folder.js.map +1 -1
- package/build/src/models/HttpProject.d.ts +2 -2
- package/build/src/models/HttpProject.d.ts.map +1 -1
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/ProjectFolder.d.ts +2 -2
- package/build/src/models/ProjectFolder.d.ts.map +1 -1
- package/build/src/models/ProjectFolder.js.map +1 -1
- package/build/src/models/Request.d.ts +3 -3
- package/build/src/models/Request.d.ts.map +1 -1
- package/build/src/models/Request.js.map +1 -1
- package/build/src/models/Thing.d.ts +9 -5
- package/build/src/models/Thing.d.ts.map +1 -1
- package/build/src/models/Thing.js.map +1 -1
- package/build/src/models/TrashEntry.d.ts +2 -2
- package/build/src/models/TrashEntry.d.ts.map +1 -1
- package/build/src/models/TrashEntry.js.map +1 -1
- package/build/src/models/store/Capabilities.d.ts +5 -1
- package/build/src/models/store/Capabilities.d.ts.map +1 -1
- package/build/src/models/store/Capabilities.js.map +1 -1
- package/build/src/models/store/Deletion.d.ts +5 -1
- package/build/src/models/store/Deletion.d.ts.map +1 -1
- package/build/src/models/store/Deletion.js.map +1 -1
- package/build/src/models/store/File.d.ts +45 -37
- package/build/src/models/store/File.d.ts.map +1 -1
- package/build/src/models/store/File.js +1 -1
- package/build/src/models/store/File.js.map +1 -1
- package/build/src/models/store/Group.d.ts +3 -3
- package/build/src/models/store/Group.d.ts.map +1 -1
- package/build/src/models/store/Group.js.map +1 -1
- package/build/src/models/store/Invitation.d.ts +3 -3
- package/build/src/models/store/Invitation.d.ts.map +1 -1
- package/build/src/models/store/Invitation.js.map +1 -1
- package/build/src/models/store/Modification.d.ts +5 -1
- package/build/src/models/store/Modification.d.ts.map +1 -1
- package/build/src/models/store/Modification.js.map +1 -1
- package/build/src/models/store/Organization.d.ts +18 -13
- package/build/src/models/store/Organization.d.ts.map +1 -1
- package/build/src/models/store/Organization.js +29 -47
- package/build/src/models/store/Organization.js.map +1 -1
- package/build/src/models/store/Permission.d.ts +9 -5
- package/build/src/models/store/Permission.d.ts.map +1 -1
- package/build/src/models/store/Permission.js.map +1 -1
- package/build/src/models/store/User.d.ts +18 -6
- package/build/src/models/store/User.d.ts.map +1 -1
- package/build/src/models/store/User.js.map +1 -1
- package/build/src/models/store/UserIdentity.d.ts +9 -5
- package/build/src/models/store/UserIdentity.d.ts.map +1 -1
- package/build/src/models/store/UserIdentity.js.map +1 -1
- package/build/src/sdk/FilesSdk.d.ts +15 -15
- package/build/src/sdk/FilesSdk.d.ts.map +1 -1
- package/build/src/sdk/FilesSdk.js +1 -1
- package/build/src/sdk/FilesSdk.js.map +1 -1
- package/build/src/sdk/OrganizationsSdk.d.ts +9 -9
- package/build/src/sdk/OrganizationsSdk.d.ts.map +1 -1
- package/build/src/sdk/OrganizationsSdk.js.map +1 -1
- package/build/src/sdk/SdkMock.js +6 -6
- package/build/src/sdk/SdkMock.js.map +1 -1
- package/build/src/sdk/SharedSdk.d.ts +2 -2
- package/build/src/sdk/SharedSdk.d.ts.map +1 -1
- package/build/src/sdk/SharedSdk.js.map +1 -1
- package/build/src/sdk/StoreSdkNode.d.ts +1 -1
- package/build/src/sdk/StoreSdkNode.d.ts.map +1 -1
- package/build/src/sdk/StoreSdkNode.js.map +1 -1
- package/build/src/sdk/StoreSdkWeb.d.ts +1 -1
- package/build/src/sdk/StoreSdkWeb.d.ts.map +1 -1
- package/build/src/sdk/StoreSdkWeb.js.map +1 -1
- package/build/src/sdk/UsersSdk.d.ts +5 -5
- package/build/src/sdk/UsersSdk.d.ts.map +1 -1
- package/build/src/sdk/UsersSdk.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/exceptions/exception.ts +119 -15
- package/src/mocking/ProjectMock.ts +1 -1
- package/src/mocking/lib/File.ts +5 -5
- package/src/mocking/lib/Organization.ts +5 -3
- package/src/mocking/lib/Permission.ts +8 -8
- package/src/mocking/lib/User.ts +11 -6
- package/src/modeling/ApiFile.ts +11 -6
- package/src/modeling/ApiModel.ts +2 -2
- package/src/modeling/DataDomain.ts +2 -2
- package/src/modeling/DomainAssociation.ts +2 -2
- package/src/modeling/DomainEntity.ts +2 -2
- package/src/modeling/DomainFile.ts +11 -6
- package/src/modeling/DomainModel.ts +2 -2
- package/src/modeling/DomainNamespace.ts +2 -2
- package/src/modeling/DomainProperty.ts +2 -2
- package/src/modeling/helpers/Intelisense.ts +41 -38
- package/src/models/AiMessage.ts +3 -3
- package/src/models/AiSession.ts +3 -3
- package/src/models/CertificateFile.ts +2 -2
- package/src/models/Environment.ts +2 -2
- package/src/models/Folder.ts +13 -8
- package/src/models/HttpProject.ts +2 -2
- package/src/models/ProjectFolder.ts +2 -2
- package/src/models/Request.ts +3 -3
- package/src/models/Thing.ts +14 -9
- package/src/models/TrashEntry.ts +2 -2
- package/src/models/store/Capabilities.ts +6 -1
- package/src/models/store/Deletion.ts +6 -1
- package/src/models/store/File.ts +53 -43
- package/src/models/store/Group.ts +3 -3
- package/src/models/store/Invitation.ts +3 -3
- package/src/models/store/Modification.ts +6 -1
- package/src/models/store/Organization.ts +45 -60
- package/src/models/store/Permission.ts +17 -12
- package/src/models/store/User.ts +21 -6
- package/src/models/store/UserIdentity.ts +13 -8
- package/src/sdk/FilesSdk.ts +29 -25
- package/src/sdk/OrganizationsSdk.ts +20 -16
- package/src/sdk/SdkMock.ts +16 -16
- package/src/sdk/SharedSdk.ts +3 -3
- package/src/sdk/StoreSdkNode.ts +3 -3
- package/src/sdk/StoreSdkWeb.ts +3 -3
- package/src/sdk/UsersSdk.ts +6 -6
- package/tests/unit/exceptions/exception.spec.ts +261 -0
- package/tests/unit/mocking/current/File.spec.ts +5 -5
- package/tests/unit/mocking/current/Organization.spec.ts +4 -3
- package/tests/unit/mocking/current/Permission.spec.ts +2 -2
- package/tests/unit/mocking/current/User.spec.ts +2 -2
- package/tests/unit/modeling/domain_file.spec.ts +3 -3
- package/tests/unit/models/File/createFileCapabilities.spec.ts +3 -3
- package/tests/unit/models/File/new.spec.ts +2 -2
- package/tests/unit/models/File/setDeleted.spec.ts +3 -3
- package/tests/unit/models/File/setLastModified.spec.ts +3 -3
- package/tests/unit/models/File/toJSON.spec.ts +2 -2
- package/tests/unit/models/Folder/create.spec.ts +3 -3
- package/tests/unit/models/Permission/all.spec.ts +3 -3
- package/tests/unit/models/store/Invitation.spec.ts +2 -2
- package/tests/unit/models/store/Organization.spec.ts +100 -0
- package/tests/unit/models/store/Permission.spec.ts +16 -6
- package/tests/unit/models/thing.spec.ts +3 -3
package/package.json
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A serialized representation of an Exception.
|
|
3
|
+
* Provides a standardized structure for pure data objects,
|
|
4
|
+
* typically used when converting errors for JSON responses.
|
|
5
|
+
*/
|
|
1
6
|
export interface ExceptionSchema {
|
|
2
7
|
name: string
|
|
3
8
|
message: string
|
|
@@ -75,39 +80,49 @@ export class Exception extends Error {
|
|
|
75
80
|
*/
|
|
76
81
|
static fromRawException(init: object, defaultMessage: string): Exception {
|
|
77
82
|
const typed = init as Record<string, string | number>
|
|
78
|
-
const options: ErrorOptions & { code?: string; status?: number } = {}
|
|
79
|
-
if (typed.code) {
|
|
80
|
-
options.code = typed.code
|
|
83
|
+
const options: ErrorOptions & { code?: string; status?: number; help?: string } = {}
|
|
84
|
+
if (typed.code !== undefined) {
|
|
85
|
+
options.code = String(typed.code)
|
|
81
86
|
}
|
|
82
|
-
if (typed.status) {
|
|
83
|
-
|
|
87
|
+
if (typed.status !== undefined) {
|
|
88
|
+
const parsedStatus = Number(typed.status)
|
|
89
|
+
if (!isNaN(parsedStatus)) {
|
|
90
|
+
options.status = parsedStatus
|
|
91
|
+
}
|
|
84
92
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (typed.help) {
|
|
88
|
-
result.setHelp(typed.help as string)
|
|
93
|
+
if (typed.help !== undefined) {
|
|
94
|
+
options.help = String(typed.help)
|
|
89
95
|
}
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
const message = typed.message !== undefined ? String(typed.message) : defaultMessage
|
|
97
|
+
const result = new this(message, options)
|
|
98
|
+
if (typed.name !== undefined) {
|
|
99
|
+
result.name = String(typed.name)
|
|
92
100
|
}
|
|
93
101
|
return result
|
|
94
102
|
}
|
|
95
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Initializes a new Exception instance.
|
|
106
|
+
*
|
|
107
|
+
* @param message - The primary human-readable error message.
|
|
108
|
+
* @param options - Additional properties configuration. Accepts standard `ErrorOptions`
|
|
109
|
+
* (like `cause`), plus custom `code`, `status`, and `help`.
|
|
110
|
+
*/
|
|
96
111
|
constructor(message?: string, options?: ErrorOptions & { code?: string; status?: number; help?: string }) {
|
|
97
112
|
super(message, options)
|
|
98
113
|
|
|
99
114
|
const ErrorConstructor = this.constructor as typeof Exception
|
|
100
115
|
|
|
101
116
|
this.name = ErrorConstructor.name
|
|
102
|
-
this.message = message
|
|
103
|
-
this.status = options?.status
|
|
117
|
+
this.message = message ?? ErrorConstructor.message ?? ''
|
|
118
|
+
this.status = options?.status ?? ErrorConstructor.status ?? 500
|
|
104
119
|
|
|
105
|
-
const code = options?.code
|
|
120
|
+
const code = options?.code ?? ErrorConstructor.code
|
|
106
121
|
if (code !== undefined) {
|
|
107
122
|
this.code = code
|
|
108
123
|
}
|
|
109
124
|
|
|
110
|
-
const help = options?.help
|
|
125
|
+
const help = options?.help ?? ErrorConstructor.help
|
|
111
126
|
if (help !== undefined) {
|
|
112
127
|
this.help = help
|
|
113
128
|
}
|
|
@@ -115,25 +130,53 @@ export class Exception extends Error {
|
|
|
115
130
|
Error.captureStackTrace(this, ErrorConstructor)
|
|
116
131
|
}
|
|
117
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Assigns a human-readable help description for troubleshooting and returns
|
|
135
|
+
* the exception instance to allow for method chaining.
|
|
136
|
+
*
|
|
137
|
+
* @param help - The detailed help informational text.
|
|
138
|
+
* @returns The current exception instance.
|
|
139
|
+
*/
|
|
118
140
|
setHelp(help: string): this {
|
|
119
141
|
this.help = help
|
|
120
142
|
return this
|
|
121
143
|
}
|
|
122
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Assigns a programmatic error code and returns the exception instance
|
|
147
|
+
* to allow for method chaining.
|
|
148
|
+
*
|
|
149
|
+
* @param code - The string error code (e.g., 'E_FILE_NOT_FOUND').
|
|
150
|
+
* @returns The current exception instance.
|
|
151
|
+
*/
|
|
123
152
|
setCode(code: string): this {
|
|
124
153
|
this.code = code
|
|
125
154
|
return this
|
|
126
155
|
}
|
|
127
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Assigns an HTTP-style status code and returns the exception instance
|
|
159
|
+
* to allow for method chaining.
|
|
160
|
+
*
|
|
161
|
+
* @param status - The numeric status code (e.g., 404, 500).
|
|
162
|
+
* @returns The current exception instance.
|
|
163
|
+
*/
|
|
128
164
|
setStatus(status: number): this {
|
|
129
165
|
this.status = status
|
|
130
166
|
return this
|
|
131
167
|
}
|
|
132
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Provides the string tag used by `Object.prototype.toString`.
|
|
171
|
+
*/
|
|
133
172
|
get [Symbol.toStringTag]() {
|
|
134
173
|
return this.constructor.name
|
|
135
174
|
}
|
|
136
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Computes a string representation of the exception, including the
|
|
178
|
+
* programmatic code if one is defined.
|
|
179
|
+
*/
|
|
137
180
|
override toString(): string {
|
|
138
181
|
if (this.code) {
|
|
139
182
|
return `${this.name} [${this.code}]: ${this.message}`
|
|
@@ -141,6 +184,12 @@ export class Exception extends Error {
|
|
|
141
184
|
return `${this.name}: ${this.message}`
|
|
142
185
|
}
|
|
143
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Serializes the exception into a plain JavaScript object.
|
|
189
|
+
* This ensures safe passing across boundaries and correct format in JSON responses.
|
|
190
|
+
*
|
|
191
|
+
* @returns The serialized exception object matching `ExceptionSchema`.
|
|
192
|
+
*/
|
|
144
193
|
toJSON(): ExceptionSchema {
|
|
145
194
|
const result: ExceptionSchema = {
|
|
146
195
|
name: this.name,
|
|
@@ -158,3 +207,58 @@ export class Exception extends Error {
|
|
|
158
207
|
return result
|
|
159
208
|
}
|
|
160
209
|
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Converts a standard Error object (or thrown primitive) into an Exception instance.
|
|
213
|
+
* This function extracts relevant properties from the raw error
|
|
214
|
+
* and sets them on the Exception instance, allowing for a more
|
|
215
|
+
* consistent error handling experience across the application.
|
|
216
|
+
* @param error The unknown error value to convert.
|
|
217
|
+
* @param defaults Optional default properties to apply if they are missing on the Error object.
|
|
218
|
+
* @returns An Exception instance with properties set from the Error object.
|
|
219
|
+
*/
|
|
220
|
+
export function fromError(error: unknown, defaults: Partial<ExceptionSchema> = {}): Exception {
|
|
221
|
+
let message: string | undefined
|
|
222
|
+
let typed: Record<string, string | number> = {}
|
|
223
|
+
|
|
224
|
+
if (error instanceof Error) {
|
|
225
|
+
message = error.message
|
|
226
|
+
typed = error as unknown as Record<string, string | number>
|
|
227
|
+
} else if (typeof error === 'string') {
|
|
228
|
+
message = error
|
|
229
|
+
} else if (error !== null && typeof error === 'object') {
|
|
230
|
+
typed = error as Record<string, string | number>
|
|
231
|
+
if (typeof typed.message === 'string') {
|
|
232
|
+
message = typed.message
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const e = new Exception(message || defaults.message || 'An error occurred')
|
|
237
|
+
|
|
238
|
+
if (typed.code !== undefined) {
|
|
239
|
+
e.code = String(typed.code)
|
|
240
|
+
} else if (defaults.code !== undefined) {
|
|
241
|
+
e.code = defaults.code
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (typed.status !== undefined) {
|
|
245
|
+
const status = Number(typed.status)
|
|
246
|
+
e.status = isNaN(status) ? (defaults.status ?? 500) : status
|
|
247
|
+
} else if (defaults.status !== undefined) {
|
|
248
|
+
e.status = defaults.status
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (typed.help !== undefined) {
|
|
252
|
+
e.setHelp(String(typed.help))
|
|
253
|
+
} else if (defaults.help !== undefined) {
|
|
254
|
+
e.setHelp(defaults.help)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (typed.name !== undefined) {
|
|
258
|
+
e.name = String(typed.name)
|
|
259
|
+
} else if (defaults.name !== undefined) {
|
|
260
|
+
e.name = defaults.name
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return e
|
|
264
|
+
}
|
|
@@ -10,7 +10,7 @@ import { HostRules } from './lib/HostRules.js'
|
|
|
10
10
|
|
|
11
11
|
export type { IRequestLogInit } from './lib/Request.js'
|
|
12
12
|
export type { IResponseInit } from './lib/Response.js'
|
|
13
|
-
export type { IUserInit } from './lib/User.js'
|
|
13
|
+
export type { UserInitSchema, IUserInit } from './lib/User.js'
|
|
14
14
|
export type { IHttpHistoryInit, IHttpHistoryListInit } from './lib/History.js'
|
|
15
15
|
|
|
16
16
|
export class ProjectMock extends DataMock {
|
package/src/mocking/lib/File.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { faker } from '@faker-js/faker'
|
|
2
2
|
import { ProjectKind, DomainFileKind, CertificateFileKind, FolderKind, ApiFileKind } from '../../models/kinds.js'
|
|
3
|
-
import { File as CoreFile, type
|
|
3
|
+
import { File as CoreFile, type FileSchema, type FileBreadcrumb } from '../../models/store/File.js'
|
|
4
4
|
import { nanoid } from '../../nanoid.js'
|
|
5
5
|
|
|
6
6
|
export class File {
|
|
@@ -10,7 +10,7 @@ export class File {
|
|
|
10
10
|
* @param init Optional values to be present in the object.
|
|
11
11
|
* @returns Random file
|
|
12
12
|
*/
|
|
13
|
-
file(init: Partial<
|
|
13
|
+
file(init: Partial<FileSchema> = {}): FileSchema {
|
|
14
14
|
const {
|
|
15
15
|
kind = faker.helpers.arrayElement([ProjectKind, DomainFileKind, CertificateFileKind, ApiFileKind] as const),
|
|
16
16
|
info = { name: faker.system.fileName() },
|
|
@@ -23,7 +23,7 @@ export class File {
|
|
|
23
23
|
* @param size Number of files to generate. Default is 25.
|
|
24
24
|
* @returns List of random files
|
|
25
25
|
*/
|
|
26
|
-
files(size = 25, init?: Partial<
|
|
26
|
+
files(size = 25, init?: Partial<FileSchema>): FileSchema[] {
|
|
27
27
|
const result = []
|
|
28
28
|
for (let i = 0; i < size; i++) {
|
|
29
29
|
result.push(this.file(init))
|
|
@@ -36,7 +36,7 @@ export class File {
|
|
|
36
36
|
* @param init Optional values to be present in the object.
|
|
37
37
|
* @returns Random folder
|
|
38
38
|
*/
|
|
39
|
-
folder(init: Partial<
|
|
39
|
+
folder(init: Partial<FileSchema> = {}): FileSchema {
|
|
40
40
|
return this.file({ kind: FolderKind, ...init })
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -45,7 +45,7 @@ export class File {
|
|
|
45
45
|
* @param size Number of folders to generate. Default is 25.
|
|
46
46
|
* @returns List of random folders
|
|
47
47
|
*/
|
|
48
|
-
folders(size = 25, init?: Partial<
|
|
48
|
+
folders(size = 25, init?: Partial<FileSchema>): FileSchema[] {
|
|
49
49
|
const result = []
|
|
50
50
|
for (let i = 0; i < size; i++) {
|
|
51
51
|
result.push(this.folder(init))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { faker } from '@faker-js/faker'
|
|
2
2
|
import { OrganizationKind } from '../../models/kinds.js'
|
|
3
3
|
import { nanoid } from '../../nanoid.js'
|
|
4
|
-
import type {
|
|
4
|
+
import type { OrganizationSchema } from '../../models/store/Organization.js'
|
|
5
5
|
|
|
6
6
|
export class Organization {
|
|
7
7
|
/**
|
|
@@ -9,10 +9,11 @@ export class Organization {
|
|
|
9
9
|
* @param init Optional values to be present in the object.
|
|
10
10
|
* @returns Random organization
|
|
11
11
|
*/
|
|
12
|
-
organization(init: Partial<
|
|
12
|
+
organization(init: Partial<OrganizationSchema> = {}): OrganizationSchema {
|
|
13
13
|
const {
|
|
14
14
|
key = nanoid(),
|
|
15
15
|
name = faker.company.name(),
|
|
16
|
+
slug = faker.helpers.slugify(name),
|
|
16
17
|
createdBy = nanoid(),
|
|
17
18
|
createdDate = faker.date.past().getTime(),
|
|
18
19
|
grantType = faker.helpers.arrayElement(['owner', 'manager', 'editor', 'viewer'] as const),
|
|
@@ -21,6 +22,7 @@ export class Organization {
|
|
|
21
22
|
kind: OrganizationKind,
|
|
22
23
|
key,
|
|
23
24
|
name,
|
|
25
|
+
slug,
|
|
24
26
|
createdBy,
|
|
25
27
|
createdDate,
|
|
26
28
|
grantType,
|
|
@@ -32,7 +34,7 @@ export class Organization {
|
|
|
32
34
|
* @param size Number of organizations to generate. Default is 25.
|
|
33
35
|
* @returns List of random organizations
|
|
34
36
|
*/
|
|
35
|
-
organizations(size = 25, init?: Partial<
|
|
37
|
+
organizations(size = 25, init?: Partial<OrganizationSchema>): OrganizationSchema[] {
|
|
36
38
|
const result = []
|
|
37
39
|
for (let i = 0; i < size; i++) {
|
|
38
40
|
result.push(this.organization(init))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { faker } from '@faker-js/faker'
|
|
2
2
|
import { nanoid } from '../../nanoid.js'
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
PermissionSchema,
|
|
5
5
|
Kind as PermissionKind,
|
|
6
6
|
type PermissionRole,
|
|
7
7
|
type PermissionType,
|
|
@@ -14,11 +14,11 @@ export class Permission {
|
|
|
14
14
|
* @param init Configuration options for the permission object.
|
|
15
15
|
* @returns Random permission
|
|
16
16
|
*/
|
|
17
|
-
permission(init: Partial<
|
|
17
|
+
permission(init: Partial<PermissionSchema> = {}): PermissionSchema {
|
|
18
18
|
const type = init.type ?? faker.helpers.arrayElement(['user', 'group', 'organization'] as PermissionType[])
|
|
19
19
|
const role = init.role ?? faker.helpers.arrayElement(['reader', 'commenter', 'writer', 'owner'] as PermissionRole[])
|
|
20
20
|
|
|
21
|
-
const result:
|
|
21
|
+
const result: PermissionSchema = {
|
|
22
22
|
kind: PermissionKind,
|
|
23
23
|
key: init.key ?? nanoid(),
|
|
24
24
|
type,
|
|
@@ -62,7 +62,7 @@ export class Permission {
|
|
|
62
62
|
* @param init Configuration options for the permission object.
|
|
63
63
|
* @returns Random user permission
|
|
64
64
|
*/
|
|
65
|
-
userPermission(init: Partial<
|
|
65
|
+
userPermission(init: Partial<PermissionSchema> = {}): PermissionSchema {
|
|
66
66
|
return this.permission({ ...init, type: 'user' })
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -71,7 +71,7 @@ export class Permission {
|
|
|
71
71
|
* @param init Configuration options for the permission object.
|
|
72
72
|
* @returns Random group permission
|
|
73
73
|
*/
|
|
74
|
-
groupPermission(init: Partial<
|
|
74
|
+
groupPermission(init: Partial<PermissionSchema> = {}): PermissionSchema {
|
|
75
75
|
return this.permission({ ...init, type: 'group' })
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -80,7 +80,7 @@ export class Permission {
|
|
|
80
80
|
* @param init Configuration options for the permission object.
|
|
81
81
|
* @returns Random organization permission
|
|
82
82
|
*/
|
|
83
|
-
organizationPermission(init: Partial<
|
|
83
|
+
organizationPermission(init: Partial<PermissionSchema> = {}): PermissionSchema {
|
|
84
84
|
return this.permission({ ...init, type: 'organization' })
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -90,8 +90,8 @@ export class Permission {
|
|
|
90
90
|
* @param init Configuration options for the permission object.
|
|
91
91
|
* @returns List of random permissions
|
|
92
92
|
*/
|
|
93
|
-
permissions(size = 25, init: Partial<
|
|
94
|
-
const result:
|
|
93
|
+
permissions(size = 25, init: Partial<PermissionSchema> = {}): PermissionSchema[] {
|
|
94
|
+
const result: PermissionSchema[] = []
|
|
95
95
|
for (let i = 0; i < size; i++) {
|
|
96
96
|
result.push(this.permission(init))
|
|
97
97
|
}
|
package/src/mocking/lib/User.ts
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { faker } from '@faker-js/faker'
|
|
2
2
|
import { nanoid } from '../../nanoid.js'
|
|
3
|
-
import {
|
|
3
|
+
import { UserSchema, Kind as UserKind } from '../../models/store/User.js'
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface UserInitSchema {
|
|
6
6
|
noEmail?: boolean
|
|
7
7
|
noPicture?: boolean
|
|
8
8
|
noProvider?: boolean
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use {@link UserInitSchema} instead.
|
|
13
|
+
*/
|
|
14
|
+
export type IUserInit = UserInitSchema
|
|
15
|
+
|
|
11
16
|
export class User {
|
|
12
17
|
/**
|
|
13
18
|
* Generates a random user object.
|
|
14
19
|
* @param init Configuration options for the user object.
|
|
15
20
|
* @returns Random user
|
|
16
21
|
*/
|
|
17
|
-
user(init:
|
|
18
|
-
const result:
|
|
22
|
+
user(init: UserInitSchema = {}): UserSchema {
|
|
23
|
+
const result: UserSchema = {
|
|
19
24
|
kind: UserKind,
|
|
20
25
|
key: nanoid(),
|
|
21
26
|
name: faker.person.fullName(),
|
|
@@ -51,8 +56,8 @@ export class User {
|
|
|
51
56
|
* @param init Configuration options for the user object.
|
|
52
57
|
* @returns List of random users
|
|
53
58
|
*/
|
|
54
|
-
users(size = 25, init:
|
|
55
|
-
const result:
|
|
59
|
+
users(size = 25, init: UserInitSchema = {}): UserSchema[] {
|
|
60
|
+
const result: UserSchema[] = []
|
|
56
61
|
for (let i = 0; i < size; i++) {
|
|
57
62
|
result.push(this.user(init))
|
|
58
63
|
}
|
package/src/modeling/ApiFile.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { File, type
|
|
1
|
+
import { File, type FileSchema } from '../models/store/File.js'
|
|
2
2
|
import { ApiFileKind } from '../models/kinds.js'
|
|
3
3
|
import { ApiModel, ApiModelSchema } from './ApiModel.js'
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface ApiFileSchema extends FileSchema {
|
|
6
6
|
kind: typeof ApiFileKind
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use {@link ApiFileSchema} instead.
|
|
11
|
+
*/
|
|
12
|
+
export type IApiFile = ApiFileSchema
|
|
13
|
+
|
|
9
14
|
/**
|
|
10
15
|
* Used by the store. A file definition for the ApiModel.
|
|
11
16
|
*/
|
|
@@ -31,20 +36,20 @@ export class ApiFile extends File {
|
|
|
31
36
|
return new ApiFile({ key: final.key, info: final.info })
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
constructor(state: Partial<
|
|
39
|
+
constructor(state: Partial<ApiFileSchema> = {}) {
|
|
35
40
|
super({ ...state, kind: ApiFileKind })
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
static isApiFile(input: unknown): boolean {
|
|
39
|
-
const typed = input as
|
|
44
|
+
const typed = input as ApiFileSchema
|
|
40
45
|
if (!input || typed.kind !== ApiFileKind) {
|
|
41
46
|
return false
|
|
42
47
|
}
|
|
43
48
|
return true
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
override toJSON():
|
|
47
|
-
const result:
|
|
51
|
+
override toJSON(): ApiFileSchema {
|
|
52
|
+
const result: ApiFileSchema = {
|
|
48
53
|
...super.toJSON(),
|
|
49
54
|
kind: ApiFileKind,
|
|
50
55
|
}
|
package/src/modeling/ApiModel.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nanoid } from '../nanoid.js'
|
|
2
2
|
import { ApiModelKind, DataDomainKind, ExposedEntityKind } from '../models/kinds.js'
|
|
3
|
-
import { type
|
|
3
|
+
import { type ThingSchema, Thing } from '../models/Thing.js'
|
|
4
4
|
import type {
|
|
5
5
|
AssociationTarget,
|
|
6
6
|
AuthenticationConfiguration,
|
|
@@ -66,7 +66,7 @@ export interface ApiModelSchema extends DependentModelSchema {
|
|
|
66
66
|
/**
|
|
67
67
|
* Contains the name, display name, description, and the version of the API model schema.
|
|
68
68
|
*/
|
|
69
|
-
info:
|
|
69
|
+
info: ThingSchema
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* The designated Data Entity that represents a "User".
|
|
@@ -23,13 +23,13 @@ import { type DomainModelSchema, DomainModel } from './DomainModel.js'
|
|
|
23
23
|
import { type DomainEntitySchema, DomainEntity } from './DomainEntity.js'
|
|
24
24
|
import { DomainAssociation, DomainAssociationSchema } from './DomainAssociation.js'
|
|
25
25
|
import { DomainProperty, DomainPropertySchema } from './DomainProperty.js'
|
|
26
|
-
import { type
|
|
26
|
+
import { type ThingSchema, Thing } from '../models/Thing.js'
|
|
27
27
|
import { removeGraphNode } from './GraphUtils.js'
|
|
28
28
|
import { serialize, deserialize, mergeGraph, removeForeignGraph } from './DomainSerialization.js'
|
|
29
29
|
import { DependentModel, type DependentModelSchema, type DomainDependency } from './DependentModel.js'
|
|
30
30
|
|
|
31
31
|
export interface DataDomainSchema extends DependentModelSchema {
|
|
32
|
-
info:
|
|
32
|
+
info: ThingSchema
|
|
33
33
|
kind: typeof DataDomainKind
|
|
34
34
|
key: string
|
|
35
35
|
graph?: SerializedGraph
|
|
@@ -2,7 +2,7 @@ import type { DataDomain } from './DataDomain.js'
|
|
|
2
2
|
import { DomainAssociationKind } from '../models/kinds.js'
|
|
3
3
|
import { DomainElement, type DomainElementSchema } from './DomainElement.js'
|
|
4
4
|
import { nanoid } from '../nanoid.js'
|
|
5
|
-
import { type
|
|
5
|
+
import { type ThingSchema, Thing } from '../models/Thing.js'
|
|
6
6
|
import { observed, retargetChange, toRaw } from '../decorators/observed.js'
|
|
7
7
|
import type { DomainEntity } from './DomainEntity.js'
|
|
8
8
|
import type { Shapes } from '@api-client/amf-core'
|
|
@@ -37,7 +37,7 @@ export interface DomainAssociationSchema extends DomainElementSchema {
|
|
|
37
37
|
/**
|
|
38
38
|
* The data association description.
|
|
39
39
|
*/
|
|
40
|
-
info:
|
|
40
|
+
info: ThingSchema
|
|
41
41
|
/**
|
|
42
42
|
* Wether the data association is required.
|
|
43
43
|
*/
|
|
@@ -2,7 +2,7 @@ import type { DataDomain } from './DataDomain.js'
|
|
|
2
2
|
import { DomainAssociationKind, DomainEntityKind, DomainPropertyKind } from '../models/kinds.js'
|
|
3
3
|
import { DomainElement, type DomainElementSchema } from './DomainElement.js'
|
|
4
4
|
import { nanoid } from '../nanoid.js'
|
|
5
|
-
import { type
|
|
5
|
+
import { type ThingSchema, Thing } from '../models/Thing.js'
|
|
6
6
|
import { observed, retargetChange, toRaw } from '../decorators/observed.js'
|
|
7
7
|
import type { Shapes, IShapeRenderOptions } from '@api-client/amf-core'
|
|
8
8
|
import { ApiSchemaGenerator } from '@api-client/amf-core'
|
|
@@ -34,7 +34,7 @@ export interface DomainEntitySchema extends DomainElementSchema {
|
|
|
34
34
|
/**
|
|
35
35
|
* The domain entity description.
|
|
36
36
|
*/
|
|
37
|
-
info:
|
|
37
|
+
info: ThingSchema
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Optional general purpose tags for the UI.
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { File, type
|
|
1
|
+
import { File, type FileSchema } from '../models/store/File.js'
|
|
2
2
|
import type { DataDomain, DataDomainSchema } from './DataDomain.js'
|
|
3
3
|
import { DomainFileKind } from '../models/kinds.js'
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface DomainFileSchema extends FileSchema {
|
|
6
6
|
kind: typeof DomainFileKind
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use {@link DomainFileSchema} instead.
|
|
11
|
+
*/
|
|
12
|
+
export type IDomainFile = DomainFileSchema
|
|
13
|
+
|
|
9
14
|
/**
|
|
10
15
|
* Used by the store. A file definition for the DataDomain
|
|
11
16
|
*/
|
|
@@ -31,20 +36,20 @@ export class DomainFile extends File {
|
|
|
31
36
|
return new DomainFile({ key: final.key, info: final.info })
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
constructor(state: Partial<
|
|
39
|
+
constructor(state: Partial<DomainFileSchema> = {}) {
|
|
35
40
|
super({ ...state, kind: DomainFileKind })
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
static isDomainFile(input: unknown): boolean {
|
|
39
|
-
const typed = input as
|
|
44
|
+
const typed = input as DomainFileSchema
|
|
40
45
|
if (!input || typed.kind !== DomainFileKind) {
|
|
41
46
|
return false
|
|
42
47
|
}
|
|
43
48
|
return true
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
override toJSON():
|
|
47
|
-
const result:
|
|
51
|
+
override toJSON(): DomainFileSchema {
|
|
52
|
+
const result: DomainFileSchema = {
|
|
48
53
|
...super.toJSON(),
|
|
49
54
|
kind: DomainFileKind,
|
|
50
55
|
}
|
|
@@ -2,7 +2,7 @@ import type { DataDomain } from './DataDomain.js'
|
|
|
2
2
|
import { DomainEntityKind, DomainModelKind } from '../models/kinds.js'
|
|
3
3
|
import { DomainElement, DomainElementSchema } from './DomainElement.js'
|
|
4
4
|
import { nanoid } from '../nanoid.js'
|
|
5
|
-
import { type
|
|
5
|
+
import { type ThingSchema, Thing } from '../models/Thing.js'
|
|
6
6
|
import { observed, retargetChange } from '../decorators/observed.js'
|
|
7
7
|
import type { DomainNamespace } from './DomainNamespace.js'
|
|
8
8
|
import type { FileBreadcrumb } from '../models/store/File.js'
|
|
@@ -29,7 +29,7 @@ export interface DomainModelSchema extends DomainElementSchema {
|
|
|
29
29
|
/**
|
|
30
30
|
* The data model description.
|
|
31
31
|
*/
|
|
32
|
-
info:
|
|
32
|
+
info: ThingSchema
|
|
33
33
|
/**
|
|
34
34
|
* The ordered list of entities in the schema.
|
|
35
35
|
*/
|
|
@@ -2,7 +2,7 @@ import type { DataDomain } from './DataDomain.js'
|
|
|
2
2
|
import { DomainModelKind, DomainNamespaceKind } from '../models/kinds.js'
|
|
3
3
|
import { DomainElement, DomainElementSchema } from './DomainElement.js'
|
|
4
4
|
import { nanoid } from '../nanoid.js'
|
|
5
|
-
import {
|
|
5
|
+
import { ThingSchema, Thing } from '../models/Thing.js'
|
|
6
6
|
import { observed, retargetChange } from '../decorators/observed.js'
|
|
7
7
|
import { DomainModel, DomainModelSchema } from './DomainModel.js'
|
|
8
8
|
import { RemoveNamespaceException } from '../exceptions/remove_namespace_exception.js'
|
|
@@ -28,7 +28,7 @@ export interface DomainNamespaceSchema extends DomainElementSchema {
|
|
|
28
28
|
/**
|
|
29
29
|
* The data namespace description.
|
|
30
30
|
*/
|
|
31
|
-
info:
|
|
31
|
+
info: ThingSchema
|
|
32
32
|
/**
|
|
33
33
|
* The ordered list of fields (namespace and models) in the schema.
|
|
34
34
|
* These only keep references to define the order of these properties
|
|
@@ -2,7 +2,7 @@ import type { DataDomain } from './DataDomain.js'
|
|
|
2
2
|
import { DomainPropertyKind } from '../models/kinds.js'
|
|
3
3
|
import { DomainElement, type DomainElementSchema } from './DomainElement.js'
|
|
4
4
|
import { nanoid } from '../nanoid.js'
|
|
5
|
-
import { type
|
|
5
|
+
import { type ThingSchema, Thing } from '../models/Thing.js'
|
|
6
6
|
import { observed, retargetChange, toRaw } from '../decorators/observed.js'
|
|
7
7
|
import {
|
|
8
8
|
type BinaryFormat,
|
|
@@ -30,7 +30,7 @@ export interface DomainPropertySchema extends DomainElementSchema {
|
|
|
30
30
|
/**
|
|
31
31
|
* The domain property description.
|
|
32
32
|
*/
|
|
33
|
-
info:
|
|
33
|
+
info: ThingSchema
|
|
34
34
|
/**
|
|
35
35
|
* Wether the data property is required.
|
|
36
36
|
*/
|