@api-client/core 0.19.17 → 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/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/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/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/src/sdk/UsersSdk.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
SdkOptions,
|
|
8
8
|
} from './SdkBase.js'
|
|
9
9
|
import { RouteBuilder } from './RouteBuilder.js'
|
|
10
|
-
import {
|
|
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
|
|
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
|
|
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
|
|
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<
|
|
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:
|
|
101
|
+
let data: UserSchema
|
|
102
102
|
try {
|
|
103
103
|
data = JSON.parse(result.body)
|
|
104
104
|
} catch {
|
|
@@ -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 {
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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 {
|
|
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<
|
|
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<
|
|
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 {
|
|
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
|
|
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 {
|
|
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
|
|
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,
|
|
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:
|
|
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:
|
|
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,
|
|
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
|
|
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
|
|
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,
|
|
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:
|
|
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,
|
|
2
|
+
import { File, UserSchema } from '../../../../src/index.js'
|
|
3
3
|
|
|
4
4
|
test.group('File.setDeleted()', () => {
|
|
5
|
-
const user:
|
|
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:
|
|
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,
|
|
2
|
+
import { File, UserSchema } from '../../../../src/index.js'
|
|
3
3
|
|
|
4
4
|
test.group('File.setLastModified()', () => {
|
|
5
|
-
const user:
|
|
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:
|
|
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,
|
|
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:
|
|
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,
|
|
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:
|
|
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:
|
|
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 {
|
|
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:
|
|
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:
|
|
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
|
|
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:
|
|
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',
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { test } from '@japa/runner'
|
|
2
|
+
import { Organization } from '../../../../src/models/store/Organization.js'
|
|
3
|
+
import type { OrganizationSchema } from '../../../../src/models/store/Organization.js'
|
|
4
|
+
import { OrganizationKind } from '../../../../src/models/kinds.js'
|
|
5
|
+
|
|
6
|
+
test.group('Organization model', () => {
|
|
7
|
+
test('createSchema() returns default values', ({ assert }) => {
|
|
8
|
+
const result = Organization.createSchema()
|
|
9
|
+
assert.equal(result.kind, OrganizationKind)
|
|
10
|
+
assert.isString(result.key)
|
|
11
|
+
assert.equal(result.name, 'Unnamed organization')
|
|
12
|
+
assert.equal(result.slug, '')
|
|
13
|
+
assert.equal(result.createdBy, '')
|
|
14
|
+
assert.isNumber(result.createdDate)
|
|
15
|
+
assert.isFalse(result.deleted)
|
|
16
|
+
assert.isUndefined(result.deletedInfo)
|
|
17
|
+
assert.equal(result.grantType, 'viewer')
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
test('createSchema(init) assigns values', ({ assert }) => {
|
|
21
|
+
const init: Partial<OrganizationSchema> = {
|
|
22
|
+
key: 'test-key',
|
|
23
|
+
name: 'Test Org',
|
|
24
|
+
slug: 'test-org',
|
|
25
|
+
createdBy: 'user1',
|
|
26
|
+
createdDate: 12345,
|
|
27
|
+
deleted: true,
|
|
28
|
+
deletedInfo: {
|
|
29
|
+
time: 123,
|
|
30
|
+
user: 'user2',
|
|
31
|
+
byMe: false,
|
|
32
|
+
},
|
|
33
|
+
grantType: 'owner',
|
|
34
|
+
}
|
|
35
|
+
const result = Organization.createSchema(init)
|
|
36
|
+
assert.equal(result.key, 'test-key')
|
|
37
|
+
assert.equal(result.name, 'Test Org')
|
|
38
|
+
assert.equal(result.slug, 'test-org')
|
|
39
|
+
assert.equal(result.createdBy, 'user1')
|
|
40
|
+
assert.equal(result.createdDate, 12345)
|
|
41
|
+
assert.isTrue(result.deleted)
|
|
42
|
+
assert.deepEqual(result.deletedInfo, { time: 123, user: 'user2', byMe: false })
|
|
43
|
+
assert.equal(result.grantType, 'owner')
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test('constructor() initializes with default values', ({ assert }) => {
|
|
47
|
+
const organization = new Organization()
|
|
48
|
+
assert.equal(organization.kind, OrganizationKind)
|
|
49
|
+
assert.isString(organization.key)
|
|
50
|
+
assert.equal(organization.name, 'Unnamed organization')
|
|
51
|
+
assert.equal(organization.slug, '')
|
|
52
|
+
assert.equal(organization.createdBy, '')
|
|
53
|
+
assert.isNumber(organization.createdDate)
|
|
54
|
+
assert.isFalse(organization.deleted)
|
|
55
|
+
assert.isUndefined(organization.deletedInfo)
|
|
56
|
+
assert.equal(organization.grantType, 'viewer')
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('constructor(init) assigns values', ({ assert }) => {
|
|
60
|
+
const init: Partial<OrganizationSchema> = {
|
|
61
|
+
name: 'Test Org',
|
|
62
|
+
slug: 'test-org',
|
|
63
|
+
deletedInfo: { time: 123, user: 'user2', byMe: false },
|
|
64
|
+
}
|
|
65
|
+
const organization = new Organization(init)
|
|
66
|
+
assert.equal(organization.name, 'Test Org')
|
|
67
|
+
assert.equal(organization.slug, 'test-org')
|
|
68
|
+
assert.deepEqual(organization.deletedInfo, { time: 123, user: 'user2', byMe: false })
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test('toJSON() returns the schema representation', ({ assert }) => {
|
|
72
|
+
const init: Partial<OrganizationSchema> = {
|
|
73
|
+
key: 'test-key',
|
|
74
|
+
name: 'Test Org',
|
|
75
|
+
slug: 'test-org',
|
|
76
|
+
createdBy: 'user1',
|
|
77
|
+
createdDate: 12345,
|
|
78
|
+
deleted: true,
|
|
79
|
+
deletedInfo: {
|
|
80
|
+
time: 123,
|
|
81
|
+
user: 'user2',
|
|
82
|
+
byMe: false,
|
|
83
|
+
},
|
|
84
|
+
grantType: 'owner',
|
|
85
|
+
}
|
|
86
|
+
const organization = new Organization(init)
|
|
87
|
+
const result = organization.toJSON()
|
|
88
|
+
assert.deepEqual(result, {
|
|
89
|
+
kind: OrganizationKind,
|
|
90
|
+
key: 'test-key',
|
|
91
|
+
name: 'Test Org',
|
|
92
|
+
slug: 'test-org',
|
|
93
|
+
createdBy: 'user1',
|
|
94
|
+
createdDate: 12345,
|
|
95
|
+
deleted: true,
|
|
96
|
+
deletedInfo: { time: 123, user: 'user2', byMe: false },
|
|
97
|
+
grantType: 'owner',
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
})
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { test } from '@japa/runner'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
PermissionSchema,
|
|
4
|
+
Permission,
|
|
5
|
+
PermissionRole,
|
|
6
|
+
PermissionType,
|
|
7
|
+
} from '../../../../src/models/store/Permission.js'
|
|
3
8
|
|
|
4
9
|
test.group('Permission.hasRoleIn()', () => {
|
|
5
|
-
const createPerm = (
|
|
10
|
+
const createPerm = (
|
|
11
|
+
role: PermissionRole,
|
|
12
|
+
depth: number,
|
|
13
|
+
type: PermissionType = 'user',
|
|
14
|
+
id = 'id'
|
|
15
|
+
): PermissionSchema => ({
|
|
6
16
|
kind: 'Core#Permission',
|
|
7
17
|
key: 'key',
|
|
8
18
|
role,
|
|
@@ -108,7 +118,7 @@ test.group('Permission.constructor()', () => {
|
|
|
108
118
|
})
|
|
109
119
|
|
|
110
120
|
test('creates from object', ({ assert }) => {
|
|
111
|
-
const init:
|
|
121
|
+
const init: PermissionSchema = {
|
|
112
122
|
kind: 'Core#Permission',
|
|
113
123
|
key: 'key',
|
|
114
124
|
role: 'owner',
|
|
@@ -125,11 +135,11 @@ test.group('Permission.constructor()', () => {
|
|
|
125
135
|
})
|
|
126
136
|
|
|
127
137
|
test('throws when input is not a permission', ({ assert }) => {
|
|
128
|
-
assert.throws(() => new Permission({ kind: 'Wrong' } as unknown as
|
|
138
|
+
assert.throws(() => new Permission({ kind: 'Wrong' } as unknown as PermissionSchema), /Not a permission/)
|
|
129
139
|
})
|
|
130
140
|
|
|
131
141
|
test('restores optional fields', ({ assert }) => {
|
|
132
|
-
const init:
|
|
142
|
+
const init: PermissionSchema = {
|
|
133
143
|
kind: 'Core#Permission',
|
|
134
144
|
key: 'key',
|
|
135
145
|
role: 'owner',
|
|
@@ -184,7 +194,7 @@ test.group('Permission static factories', () => {
|
|
|
184
194
|
addingUser: 'a',
|
|
185
195
|
depth: 0,
|
|
186
196
|
sourceRule: 'direct_user_grant',
|
|
187
|
-
} as unknown as
|
|
197
|
+
} as unknown as PermissionSchema as unknown as PermissionSchema
|
|
188
198
|
const p = Permission.fromValues(base)
|
|
189
199
|
assert.equal(p.role, 'owner')
|
|
190
200
|
// fromValues generates a new key
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test } from '@japa/runner'
|
|
2
2
|
import { ThingKind } from '../../../src/models/kinds.js'
|
|
3
|
-
import { Thing,
|
|
3
|
+
import { Thing, ThingSchema } from '../../../src/models/Thing.js'
|
|
4
4
|
|
|
5
5
|
test.group('Models > Thing > Thing.fromName()', () => {
|
|
6
6
|
test('sets the kind', ({ assert }) => {
|
|
@@ -30,7 +30,7 @@ test.group('Models > Thing > constructor()', () => {
|
|
|
30
30
|
})
|
|
31
31
|
|
|
32
32
|
test('creates a Thing from the schema values', ({ assert }) => {
|
|
33
|
-
const schema:
|
|
33
|
+
const schema: ThingSchema = {
|
|
34
34
|
kind: ThingKind,
|
|
35
35
|
name: 'a name',
|
|
36
36
|
displayName: 'a displayName',
|
|
@@ -46,7 +46,7 @@ test.group('Models > Thing > constructor()', () => {
|
|
|
46
46
|
})
|
|
47
47
|
|
|
48
48
|
test('creates a Thing from the JSON schema string', ({ assert }) => {
|
|
49
|
-
const schema:
|
|
49
|
+
const schema: ThingSchema = {
|
|
50
50
|
kind: ThingKind,
|
|
51
51
|
name: 'a name',
|
|
52
52
|
displayName: 'a displayName',
|