@api-client/core 0.12.7 → 0.12.9
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 +2 -1
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +2 -1
- package/build/src/browser.js.map +1 -1
- package/build/src/index.d.ts +2 -1
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +2 -1
- package/build/src/index.js.map +1 -1
- package/build/src/models/kinds.d.ts +2 -0
- package/build/src/models/kinds.d.ts.map +1 -1
- package/build/src/models/kinds.js +2 -0
- package/build/src/models/kinds.js.map +1 -1
- package/build/src/models/store/Invitation.d.ts +146 -0
- package/build/src/models/store/Invitation.d.ts.map +1 -0
- package/build/src/models/store/Invitation.js +186 -0
- package/build/src/models/store/Invitation.js.map +1 -0
- package/build/src/models/store/Organization.d.ts +4 -4
- package/build/src/models/store/Organization.d.ts.map +1 -1
- package/build/src/models/store/Organization.js +9 -9
- package/build/src/models/store/Organization.js.map +1 -1
- package/build/src/runtime/store/HttpWeb.js +5 -5
- package/build/src/runtime/store/HttpWeb.js.map +1 -1
- package/build/src/runtime/store/OrganizationsSdk.d.ts +58 -2
- package/build/src/runtime/store/OrganizationsSdk.d.ts.map +1 -1
- package/build/src/runtime/store/OrganizationsSdk.js +215 -4
- package/build/src/runtime/store/OrganizationsSdk.js.map +1 -1
- package/build/src/runtime/store/RouteBuilder.d.ts +7 -2
- package/build/src/runtime/store/RouteBuilder.d.ts.map +1 -1
- package/build/src/runtime/store/RouteBuilder.js +21 -6
- package/build/src/runtime/store/RouteBuilder.js.map +1 -1
- package/build/src/runtime/store/Sdk.d.ts +1 -1
- package/build/src/runtime/store/Sdk.d.ts.map +1 -1
- package/build/src/runtime/store/Sdk.js +1 -1
- package/build/src/runtime/store/Sdk.js.map +1 -1
- package/build/src/runtime/store/SdkBase.d.ts +2 -2
- package/build/src/runtime/store/SdkBase.d.ts.map +1 -1
- package/build/src/runtime/store/SdkBase.js +2 -2
- package/build/src/runtime/store/SdkBase.js.map +1 -1
- package/data/models/example-generator-api.json +8 -8
- package/eslint.config.js +6 -5
- package/package.json +23 -5
- package/src/models/kinds.ts +2 -0
- package/src/models/store/Invitation.ts +287 -0
- package/src/models/store/Organization.ts +11 -12
- package/src/runtime/store/HttpWeb.ts +5 -5
- package/src/runtime/store/OrganizationsSdk.ts +225 -6
- package/src/runtime/store/RouteBuilder.ts +28 -8
- package/src/runtime/store/Sdk.ts +1 -1
- package/src/runtime/store/SdkBase.ts +2 -2
- package/tests/unit/models/store/Invitation.spec.ts +223 -0
|
@@ -42470,13 +42470,13 @@
|
|
|
42470
42470
|
"@id": "#219"
|
|
42471
42471
|
},
|
|
42472
42472
|
{
|
|
42473
|
-
"@id": "#
|
|
42473
|
+
"@id": "#216"
|
|
42474
42474
|
},
|
|
42475
42475
|
{
|
|
42476
|
-
"@id": "#
|
|
42476
|
+
"@id": "#210"
|
|
42477
42477
|
},
|
|
42478
42478
|
{
|
|
42479
|
-
"@id": "#
|
|
42479
|
+
"@id": "#213"
|
|
42480
42480
|
},
|
|
42481
42481
|
{
|
|
42482
42482
|
"@id": "#219"
|
|
@@ -43892,7 +43892,7 @@
|
|
|
43892
43892
|
"doc:ExternalDomainElement",
|
|
43893
43893
|
"doc:DomainElement"
|
|
43894
43894
|
],
|
|
43895
|
-
"doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '
|
|
43895
|
+
"doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '21'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)21 302099'\n",
|
|
43896
43896
|
"core:mediaType": "application/yaml",
|
|
43897
43897
|
"sourcemaps:sources": [
|
|
43898
43898
|
{
|
|
@@ -43913,7 +43913,7 @@
|
|
|
43913
43913
|
"doc:ExternalDomainElement",
|
|
43914
43914
|
"doc:DomainElement"
|
|
43915
43915
|
],
|
|
43916
|
-
"doc:raw": "type: 'GENERAL'\
|
|
43916
|
+
"doc:raw": "-\n type: 'GENERAL'\n value: 'info@company.be'\n-\n type: 'IT_DEPT'\n value: 'it-service@company.be'\n",
|
|
43917
43917
|
"core:mediaType": "application/yaml",
|
|
43918
43918
|
"sourcemaps:sources": [
|
|
43919
43919
|
{
|
|
@@ -43934,7 +43934,7 @@
|
|
|
43934
43934
|
"doc:ExternalDomainElement",
|
|
43935
43935
|
"doc:DomainElement"
|
|
43936
43936
|
],
|
|
43937
|
-
"doc:raw": "
|
|
43937
|
+
"doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '22'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)22 000000'\n",
|
|
43938
43938
|
"core:mediaType": "application/yaml",
|
|
43939
43939
|
"sourcemaps:sources": [
|
|
43940
43940
|
{
|
|
@@ -44781,12 +44781,12 @@
|
|
|
44781
44781
|
{
|
|
44782
44782
|
"@id": "#215/source-map/lexical/element_0",
|
|
44783
44783
|
"sourcemaps:element": "amf://id#215",
|
|
44784
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44784
|
+
"sourcemaps:value": "[(1,0)-(7,0)]"
|
|
44785
44785
|
},
|
|
44786
44786
|
{
|
|
44787
44787
|
"@id": "#218/source-map/lexical/element_0",
|
|
44788
44788
|
"sourcemaps:element": "amf://id#218",
|
|
44789
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44789
|
+
"sourcemaps:value": "[(1,0)-(6,0)]"
|
|
44790
44790
|
},
|
|
44791
44791
|
{
|
|
44792
44792
|
"@id": "#221/source-map/lexical/element_0",
|
package/eslint.config.js
CHANGED
|
@@ -2,7 +2,7 @@ import globals from 'globals'
|
|
|
2
2
|
import pluginJs from '@eslint/js'
|
|
3
3
|
import tseslint from 'typescript-eslint'
|
|
4
4
|
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
|
|
5
|
-
import noOnlyTests from 'eslint-plugin-no-only-tests'
|
|
5
|
+
import noOnlyTests from 'eslint-plugin-no-only-tests'
|
|
6
6
|
// import eslintPluginPrettier from 'eslint-plugin-prettier'
|
|
7
7
|
|
|
8
8
|
// import eslintConfigPrettier from 'eslint-config-prettier'
|
|
@@ -21,8 +21,8 @@ export const GLOBAL_IGNORE_LIST = [
|
|
|
21
21
|
'coverage/',
|
|
22
22
|
'node_modules',
|
|
23
23
|
'scripts/',
|
|
24
|
-
'test/',
|
|
25
|
-
'eslint.config.js',
|
|
24
|
+
// 'test/',
|
|
25
|
+
// 'eslint.config.js',
|
|
26
26
|
'*.min.*',
|
|
27
27
|
'*.d.ts',
|
|
28
28
|
'CHANGELOG.md',
|
|
@@ -81,7 +81,7 @@ export default [
|
|
|
81
81
|
'src/lib/calculators/DataCalculator.ts',
|
|
82
82
|
'src/lib/Buffer.ts',
|
|
83
83
|
'src/events/amf/AmfEvents.ts',
|
|
84
|
-
'src/authorization/lib/SecurityProcessor.ts'
|
|
84
|
+
'src/authorization/lib/SecurityProcessor.ts',
|
|
85
85
|
],
|
|
86
86
|
languageOptions: {
|
|
87
87
|
globals: {
|
|
@@ -101,12 +101,13 @@ export default [
|
|
|
101
101
|
{
|
|
102
102
|
files: ['tests/**/*.ts', 'test/**/*.ts'],
|
|
103
103
|
plugins: {
|
|
104
|
-
|
|
104
|
+
'no-only-tests': noOnlyTests,
|
|
105
105
|
},
|
|
106
106
|
rules: {
|
|
107
107
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
108
108
|
'@typescript-eslint/no-empty-function': 'off',
|
|
109
109
|
'no-only-tests/no-only-tests': 'error',
|
|
110
|
+
'no-console': ['warn'],
|
|
110
111
|
},
|
|
111
112
|
},
|
|
112
113
|
{
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-client/core",
|
|
3
3
|
"description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
|
|
4
|
-
"version": "0.12.
|
|
4
|
+
"version": "0.12.9",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./browser.js": {
|
|
@@ -144,8 +144,6 @@
|
|
|
144
144
|
"build:ts": "wireit",
|
|
145
145
|
"build:node": "wireit",
|
|
146
146
|
"build": "npm run build:ts && npm run lint && npm run copy:assets",
|
|
147
|
-
"lint": "wireit",
|
|
148
|
-
"lint:old": "tsc --noEmit && eslint \"**/*.{js,ts}\" --quiet --fix",
|
|
149
147
|
"prepare": "husky && npm run fixes && npm run build:ts && npm run build:api-models",
|
|
150
148
|
"fixes": "node scripts/fix-rollup-plugin.js",
|
|
151
149
|
"tsc": "wireit",
|
|
@@ -159,7 +157,13 @@
|
|
|
159
157
|
"test:node:watch": "node --import ts-node-maintained/register/esm --enable-source-maps bin/test.ts --watch",
|
|
160
158
|
"build:api-models": "node data/model.js",
|
|
161
159
|
"copy:assets": "cp -f ./oauth-popup.html ./build/oauth-popup.html",
|
|
162
|
-
"start": "echo \"Use the npm run dev instead\""
|
|
160
|
+
"start": "echo \"Use the npm run dev instead\"",
|
|
161
|
+
"lint": "npm run lint:prettier && npm run lint:eslint",
|
|
162
|
+
"lint:eslint": "wireit",
|
|
163
|
+
"lint:prettier": "wireit",
|
|
164
|
+
"format": "npm run format:prettier && npm run format:prettier",
|
|
165
|
+
"format:prettier": "wireit",
|
|
166
|
+
"format:eslint": "wireit"
|
|
163
167
|
},
|
|
164
168
|
"wireit": {
|
|
165
169
|
"test": {
|
|
@@ -242,13 +246,27 @@
|
|
|
242
246
|
".tsbuildinfo"
|
|
243
247
|
]
|
|
244
248
|
},
|
|
245
|
-
"lint": {
|
|
249
|
+
"lint:eslint": {
|
|
246
250
|
"command": "eslint --color --cache --cache-location .eslintcache .",
|
|
247
251
|
"files": [
|
|
248
252
|
"src/**/*.ts",
|
|
249
253
|
"eslint.config.js"
|
|
250
254
|
],
|
|
251
255
|
"output": []
|
|
256
|
+
},
|
|
257
|
+
"lint:prettier": {
|
|
258
|
+
"command": "prettier \"**/*.ts\" --check"
|
|
259
|
+
},
|
|
260
|
+
"format:eslint": {
|
|
261
|
+
"command": "eslint --color --cache --fix --cache-location .eslintcache .",
|
|
262
|
+
"files": [
|
|
263
|
+
"src/**/*.ts",
|
|
264
|
+
"eslint.config.js"
|
|
265
|
+
],
|
|
266
|
+
"output": []
|
|
267
|
+
},
|
|
268
|
+
"format:prettier": {
|
|
269
|
+
"command": "prettier \"**/*.ts\" --write"
|
|
252
270
|
}
|
|
253
271
|
},
|
|
254
272
|
"husky": {
|
package/src/models/kinds.ts
CHANGED
|
@@ -18,6 +18,8 @@ export const DomainAssociationKind = 'Domain#Association'
|
|
|
18
18
|
export const DomainPropertyKind = 'Domain#Property'
|
|
19
19
|
export const DataCatalogKind = 'Core#DataCatalog'
|
|
20
20
|
export const DataCatalogVersionKind = 'Core#DataCatalogVersion'
|
|
21
|
+
export const OrganizationKind = 'Core#Organization'
|
|
22
|
+
export const InvitationKind = 'Core#Invitation'
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
25
|
* @deprecated Not used anymore.
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { nanoid } from 'nanoid'
|
|
2
|
+
import { InvitationKind } from '../kinds.js'
|
|
3
|
+
import type { IDeletion } from './Deletion.js'
|
|
4
|
+
import type { UserOrganizationGrantType } from './Organization.js'
|
|
5
|
+
import type { Operation } from '@api-client/json/types.js'
|
|
6
|
+
import { Builder } from '@api-client/json/patch/builder.js'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The status of an invitation.
|
|
10
|
+
* - `pending`: The invitation has been sent but not yet responded to.
|
|
11
|
+
* - `accepted`: The invitation has been accepted by the user.
|
|
12
|
+
* - `declined`: The invitation has been declined by the user.
|
|
13
|
+
*/
|
|
14
|
+
export type InvitationStatus = 'pending' | 'accepted' | 'declined'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The schema for an invitation.
|
|
18
|
+
* This defines the structure of an invitation object in the system.
|
|
19
|
+
*/
|
|
20
|
+
export interface InvitationSchema {
|
|
21
|
+
/**
|
|
22
|
+
* The kind of the invitation.
|
|
23
|
+
*/
|
|
24
|
+
kind: typeof InvitationKind
|
|
25
|
+
/**
|
|
26
|
+
* The database ID of the invitation.
|
|
27
|
+
*/
|
|
28
|
+
key: string
|
|
29
|
+
/**
|
|
30
|
+
* The user ID of the user who sent the invitation.
|
|
31
|
+
*/
|
|
32
|
+
uid: string
|
|
33
|
+
/**
|
|
34
|
+
* The organization ID to which the invitation belongs.
|
|
35
|
+
*/
|
|
36
|
+
oid: string
|
|
37
|
+
/**
|
|
38
|
+
* The email address of the user to whom the invitation is sent.
|
|
39
|
+
*/
|
|
40
|
+
email: string
|
|
41
|
+
/**
|
|
42
|
+
* The name of the user to whom the invitation is sent.
|
|
43
|
+
* This is optional and can be empty if the user is not known.
|
|
44
|
+
*/
|
|
45
|
+
name?: string
|
|
46
|
+
/**
|
|
47
|
+
* The token used to respond to the invitation.
|
|
48
|
+
*/
|
|
49
|
+
token: string
|
|
50
|
+
/**
|
|
51
|
+
* The timestamp when the invitation expires.
|
|
52
|
+
* This is used to determine if the invitation is still valid.
|
|
53
|
+
*/
|
|
54
|
+
expiresAt: number
|
|
55
|
+
/**
|
|
56
|
+
* The timestamp when the invitation was responded to.
|
|
57
|
+
* This is set when the user accepts or declines the invitation.
|
|
58
|
+
*/
|
|
59
|
+
respondedAt?: number
|
|
60
|
+
/**
|
|
61
|
+
* The status of the invitation.
|
|
62
|
+
*/
|
|
63
|
+
status: InvitationStatus
|
|
64
|
+
/**
|
|
65
|
+
* The grant type the user will have in the organization if they accept the invitation.
|
|
66
|
+
*/
|
|
67
|
+
grantType: UserOrganizationGrantType
|
|
68
|
+
/**
|
|
69
|
+
* Whether the file object is deleted.
|
|
70
|
+
*/
|
|
71
|
+
deleted?: boolean
|
|
72
|
+
/**
|
|
73
|
+
* The information about the delete information.
|
|
74
|
+
* Always set when the `delete` is true.
|
|
75
|
+
*/
|
|
76
|
+
deletedInfo?: IDeletion
|
|
77
|
+
/**
|
|
78
|
+
* The timestamp when the invitation was created.
|
|
79
|
+
*/
|
|
80
|
+
createdAt: number
|
|
81
|
+
/**
|
|
82
|
+
* The timestamp when the invitation was last updated.
|
|
83
|
+
*/
|
|
84
|
+
updatedAt: number
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Represents an invitation to join an organization.
|
|
89
|
+
* This class implements the `InvitationSchema` interface and provides methods to create and manipulate invitations.
|
|
90
|
+
*/
|
|
91
|
+
export class Invitation implements InvitationSchema {
|
|
92
|
+
kind: typeof InvitationKind
|
|
93
|
+
key: string
|
|
94
|
+
uid: string
|
|
95
|
+
oid: string
|
|
96
|
+
email: string
|
|
97
|
+
name: string | undefined
|
|
98
|
+
token: string
|
|
99
|
+
expiresAt: number
|
|
100
|
+
respondedAt: number | undefined
|
|
101
|
+
status: InvitationStatus
|
|
102
|
+
grantType: UserOrganizationGrantType
|
|
103
|
+
deleted: boolean
|
|
104
|
+
deletedInfo: IDeletion | undefined
|
|
105
|
+
createdAt: number
|
|
106
|
+
updatedAt: number
|
|
107
|
+
|
|
108
|
+
#builder?: Builder<InvitationSchema>
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The patch builder for this invitation.
|
|
112
|
+
*/
|
|
113
|
+
get builder(): Builder<InvitationSchema> {
|
|
114
|
+
if (!this.#builder) {
|
|
115
|
+
this.#builder = new Builder(this.toJSON())
|
|
116
|
+
}
|
|
117
|
+
return this.#builder
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Creates a full invitation schema with defaults.
|
|
122
|
+
*
|
|
123
|
+
* @param input The partial invitation schema.
|
|
124
|
+
* @returns The invitation schema.
|
|
125
|
+
*/
|
|
126
|
+
static createSchema(input: Partial<InvitationSchema> = {}): InvitationSchema {
|
|
127
|
+
const {
|
|
128
|
+
key = nanoid(),
|
|
129
|
+
email,
|
|
130
|
+
oid,
|
|
131
|
+
grantType,
|
|
132
|
+
uid = '',
|
|
133
|
+
updatedAt = 0,
|
|
134
|
+
createdAt = 0,
|
|
135
|
+
expiresAt = 0,
|
|
136
|
+
status = 'pending',
|
|
137
|
+
token = '',
|
|
138
|
+
} = input
|
|
139
|
+
if (!email) {
|
|
140
|
+
throw new Error('Email is required to create an invitation schema.')
|
|
141
|
+
}
|
|
142
|
+
if (!oid) {
|
|
143
|
+
throw new Error('Organization ID is required to create an invitation schema.')
|
|
144
|
+
}
|
|
145
|
+
if (!grantType) {
|
|
146
|
+
throw new Error('Grant type is required to create an invitation schema.')
|
|
147
|
+
}
|
|
148
|
+
const result: InvitationSchema = {
|
|
149
|
+
kind: InvitationKind,
|
|
150
|
+
key,
|
|
151
|
+
uid,
|
|
152
|
+
oid,
|
|
153
|
+
email,
|
|
154
|
+
grantType,
|
|
155
|
+
token,
|
|
156
|
+
expiresAt,
|
|
157
|
+
status,
|
|
158
|
+
createdAt,
|
|
159
|
+
updatedAt,
|
|
160
|
+
}
|
|
161
|
+
if (input.name) {
|
|
162
|
+
result.name = input.name
|
|
163
|
+
}
|
|
164
|
+
if (input.token) {
|
|
165
|
+
result.token = input.token
|
|
166
|
+
}
|
|
167
|
+
if (input.expiresAt) {
|
|
168
|
+
result.expiresAt = input.expiresAt
|
|
169
|
+
}
|
|
170
|
+
if (input.respondedAt) {
|
|
171
|
+
result.respondedAt = input.respondedAt
|
|
172
|
+
}
|
|
173
|
+
if (input.status) {
|
|
174
|
+
result.status = input.status
|
|
175
|
+
}
|
|
176
|
+
if (input.deleted) {
|
|
177
|
+
result.deleted = input.deleted
|
|
178
|
+
result.deletedInfo = input.deletedInfo
|
|
179
|
+
}
|
|
180
|
+
return result
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
constructor(input?: Partial<InvitationSchema>) {
|
|
184
|
+
const init: InvitationSchema = Invitation.createSchema(input)
|
|
185
|
+
this.kind = InvitationKind
|
|
186
|
+
this.key = init.key
|
|
187
|
+
this.uid = init.uid
|
|
188
|
+
this.oid = init.oid
|
|
189
|
+
this.email = init.email
|
|
190
|
+
this.name = init.name
|
|
191
|
+
this.token = init.token
|
|
192
|
+
this.expiresAt = init.expiresAt
|
|
193
|
+
this.respondedAt = init.respondedAt
|
|
194
|
+
this.status = init.status
|
|
195
|
+
this.grantType = init.grantType
|
|
196
|
+
this.deleted = init.deleted || false
|
|
197
|
+
this.deletedInfo = init.deletedInfo
|
|
198
|
+
this.createdAt = init.createdAt
|
|
199
|
+
this.updatedAt = init.updatedAt
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
toJSON(): InvitationSchema {
|
|
203
|
+
const result: InvitationSchema = {
|
|
204
|
+
kind: this.kind,
|
|
205
|
+
key: this.key,
|
|
206
|
+
uid: this.uid,
|
|
207
|
+
oid: this.oid,
|
|
208
|
+
email: this.email,
|
|
209
|
+
token: this.token,
|
|
210
|
+
expiresAt: this.expiresAt,
|
|
211
|
+
status: this.status,
|
|
212
|
+
grantType: this.grantType,
|
|
213
|
+
deleted: this.deleted,
|
|
214
|
+
createdAt: this.createdAt,
|
|
215
|
+
updatedAt: this.updatedAt,
|
|
216
|
+
}
|
|
217
|
+
if (this.name) {
|
|
218
|
+
result.name = this.name
|
|
219
|
+
}
|
|
220
|
+
if (this.respondedAt) {
|
|
221
|
+
result.respondedAt = this.respondedAt
|
|
222
|
+
}
|
|
223
|
+
if (this.deletedInfo) {
|
|
224
|
+
result.deletedInfo = { ...this.deletedInfo }
|
|
225
|
+
}
|
|
226
|
+
return result
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Retrieves the patch operations for this invitation.
|
|
231
|
+
* This method builds a JSON Patch representation of the invitation,
|
|
232
|
+
* which can be used to update the invitation in a database or API.
|
|
233
|
+
*
|
|
234
|
+
* Use one of the `set*` methods to modify the invitation before calling this method.
|
|
235
|
+
*
|
|
236
|
+
* @returns An array of patch operations.
|
|
237
|
+
* If no changes have been made, it returns an empty array.
|
|
238
|
+
*/
|
|
239
|
+
getPatch(): Operation[] {
|
|
240
|
+
if (!this.#builder) {
|
|
241
|
+
return []
|
|
242
|
+
}
|
|
243
|
+
return this.builder.build()
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Sets the name of the user to whom the invitation is sent.
|
|
248
|
+
* If the name is the same as the current name, no operation is performed.
|
|
249
|
+
*
|
|
250
|
+
* @param name The name to set. If undefined, it will be removed.
|
|
251
|
+
*/
|
|
252
|
+
setName(name?: string): void {
|
|
253
|
+
if (name === this.name) {
|
|
254
|
+
return
|
|
255
|
+
}
|
|
256
|
+
const hasName = !!this.name
|
|
257
|
+
if (hasName && !name) {
|
|
258
|
+
this.builder.remove('/name')
|
|
259
|
+
} else {
|
|
260
|
+
// The add method handles both adding and replacing
|
|
261
|
+
this.builder.add('/name', name)
|
|
262
|
+
}
|
|
263
|
+
this.name = name
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Sets the expiration timestamp of the invitation.
|
|
268
|
+
* @param expiresAt The timestamp when the invitation expires.
|
|
269
|
+
* If the expiresAt is the same as the current expiresAt, no operation is performed.
|
|
270
|
+
*/
|
|
271
|
+
setExpiresAt(expiresAt: number): void {
|
|
272
|
+
if (this.expiresAt !== expiresAt) {
|
|
273
|
+
this.builder.replace('/expiresAt', expiresAt)
|
|
274
|
+
this.expiresAt = expiresAt
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Sets the grant type of the user in the organization.
|
|
280
|
+
*/
|
|
281
|
+
setGrantType(grantType: UserOrganizationGrantType): void {
|
|
282
|
+
if (this.grantType !== grantType) {
|
|
283
|
+
this.builder.replace('/grantType', grantType)
|
|
284
|
+
this.grantType = grantType
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { nanoid } from 'nanoid'
|
|
2
2
|
import type { IDeletion } from './Deletion.js'
|
|
3
|
+
import { OrganizationKind } from '../kinds.js'
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export type UserOrganizationGrantType = 'owner' | 'member'
|
|
5
|
+
export type UserOrganizationGrantType = 'owner' | 'manager' | 'editor' | 'viewer'
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* In the system the user identity represents registration information associated with a specific identity provider.
|
|
@@ -11,7 +10,7 @@ export type UserOrganizationGrantType = 'owner' | 'member'
|
|
|
11
10
|
* email stays consistent.
|
|
12
11
|
*/
|
|
13
12
|
export interface IOrganization {
|
|
14
|
-
kind: typeof
|
|
13
|
+
kind: typeof OrganizationKind
|
|
15
14
|
/**
|
|
16
15
|
* The database ID
|
|
17
16
|
*/
|
|
@@ -45,14 +44,14 @@ export interface IOrganization {
|
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
export class Organization implements IOrganization {
|
|
48
|
-
kind: typeof
|
|
47
|
+
kind: typeof OrganizationKind = OrganizationKind
|
|
49
48
|
key = ''
|
|
50
49
|
name = ''
|
|
51
50
|
createdBy = ''
|
|
52
51
|
createdDate = 0
|
|
53
52
|
deleted = false
|
|
54
53
|
deletedInfo?: IDeletion
|
|
55
|
-
grantType: UserOrganizationGrantType = '
|
|
54
|
+
grantType: UserOrganizationGrantType = 'viewer'
|
|
56
55
|
|
|
57
56
|
constructor(input?: string | IOrganization) {
|
|
58
57
|
let init: IOrganization
|
|
@@ -62,13 +61,13 @@ export class Organization implements IOrganization {
|
|
|
62
61
|
init = input
|
|
63
62
|
} else {
|
|
64
63
|
init = {
|
|
65
|
-
kind:
|
|
64
|
+
kind: OrganizationKind,
|
|
66
65
|
key: nanoid(),
|
|
67
66
|
name: '',
|
|
68
67
|
createdBy: '',
|
|
69
68
|
createdDate: Date.now(),
|
|
70
69
|
deleted: false,
|
|
71
|
-
grantType: '
|
|
70
|
+
grantType: 'viewer',
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
this.new(init)
|
|
@@ -85,9 +84,9 @@ export class Organization implements IOrganization {
|
|
|
85
84
|
createdDate = Date.now(),
|
|
86
85
|
deleted = false,
|
|
87
86
|
deletedInfo,
|
|
88
|
-
grantType = '
|
|
87
|
+
grantType = 'viewer',
|
|
89
88
|
} = init
|
|
90
|
-
this.kind =
|
|
89
|
+
this.kind = OrganizationKind
|
|
91
90
|
this.key = key
|
|
92
91
|
this.name = name
|
|
93
92
|
this.createdBy = createdBy
|
|
@@ -106,7 +105,7 @@ export class Organization implements IOrganization {
|
|
|
106
105
|
*/
|
|
107
106
|
static isOrganization(input: unknown): boolean {
|
|
108
107
|
const typed = input as IOrganization
|
|
109
|
-
if (!input || typed.kind !==
|
|
108
|
+
if (!input || typed.kind !== OrganizationKind) {
|
|
110
109
|
return false
|
|
111
110
|
}
|
|
112
111
|
return true
|
|
@@ -114,7 +113,7 @@ export class Organization implements IOrganization {
|
|
|
114
113
|
|
|
115
114
|
toJSON(): IOrganization {
|
|
116
115
|
const result: IOrganization = {
|
|
117
|
-
kind:
|
|
116
|
+
kind: OrganizationKind,
|
|
118
117
|
key: this.key,
|
|
119
118
|
name: this.name,
|
|
120
119
|
createdBy: this.createdBy,
|
|
@@ -11,14 +11,14 @@ export class HttpWeb extends Http {
|
|
|
11
11
|
* @returns The response info.
|
|
12
12
|
*/
|
|
13
13
|
async get(url: string, opts: IStoreRequestOptions = {}): Promise<IStoreResponse> {
|
|
14
|
-
const { method = 'GET', headers = {}, token } = opts
|
|
15
|
-
const
|
|
14
|
+
const { method = 'GET', headers = {}, token = this.sdk.token } = opts
|
|
15
|
+
const requestHeaders = new Headers({ ...headers })
|
|
16
16
|
if (token) {
|
|
17
|
-
|
|
17
|
+
requestHeaders.append('Authorization', `Bearer ${token}`)
|
|
18
18
|
}
|
|
19
19
|
const init: RequestInit = {
|
|
20
20
|
method,
|
|
21
|
-
headers:
|
|
21
|
+
headers: requestHeaders.toJSON(),
|
|
22
22
|
redirect: 'follow',
|
|
23
23
|
credentials: 'include',
|
|
24
24
|
mode: 'cors',
|
|
@@ -45,7 +45,7 @@ export class HttpWeb extends Http {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
async post(url: string, opts: IStoreRequestOptions = {}): Promise<IStoreResponse> {
|
|
48
|
-
const { method = 'POST', headers = {}, token } = opts
|
|
48
|
+
const { method = 'POST', headers = {}, token = this.sdk.token } = opts
|
|
49
49
|
const requestHeaders = new Headers({ ...headers })
|
|
50
50
|
if (token) {
|
|
51
51
|
requestHeaders.append('Authorization', `Bearer ${token}`)
|