@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
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { nanoid } from 'nanoid';
|
|
2
|
+
import { InvitationKind } from '../kinds.js';
|
|
3
|
+
import { Builder } from '@api-client/json/patch/builder.js';
|
|
4
|
+
/**
|
|
5
|
+
* Represents an invitation to join an organization.
|
|
6
|
+
* This class implements the `InvitationSchema` interface and provides methods to create and manipulate invitations.
|
|
7
|
+
*/
|
|
8
|
+
export class Invitation {
|
|
9
|
+
kind;
|
|
10
|
+
key;
|
|
11
|
+
uid;
|
|
12
|
+
oid;
|
|
13
|
+
email;
|
|
14
|
+
name;
|
|
15
|
+
token;
|
|
16
|
+
expiresAt;
|
|
17
|
+
respondedAt;
|
|
18
|
+
status;
|
|
19
|
+
grantType;
|
|
20
|
+
deleted;
|
|
21
|
+
deletedInfo;
|
|
22
|
+
createdAt;
|
|
23
|
+
updatedAt;
|
|
24
|
+
#builder;
|
|
25
|
+
/**
|
|
26
|
+
* The patch builder for this invitation.
|
|
27
|
+
*/
|
|
28
|
+
get builder() {
|
|
29
|
+
if (!this.#builder) {
|
|
30
|
+
this.#builder = new Builder(this.toJSON());
|
|
31
|
+
}
|
|
32
|
+
return this.#builder;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a full invitation schema with defaults.
|
|
36
|
+
*
|
|
37
|
+
* @param input The partial invitation schema.
|
|
38
|
+
* @returns The invitation schema.
|
|
39
|
+
*/
|
|
40
|
+
static createSchema(input = {}) {
|
|
41
|
+
const { key = nanoid(), email, oid, grantType, uid = '', updatedAt = 0, createdAt = 0, expiresAt = 0, status = 'pending', token = '', } = input;
|
|
42
|
+
if (!email) {
|
|
43
|
+
throw new Error('Email is required to create an invitation schema.');
|
|
44
|
+
}
|
|
45
|
+
if (!oid) {
|
|
46
|
+
throw new Error('Organization ID is required to create an invitation schema.');
|
|
47
|
+
}
|
|
48
|
+
if (!grantType) {
|
|
49
|
+
throw new Error('Grant type is required to create an invitation schema.');
|
|
50
|
+
}
|
|
51
|
+
const result = {
|
|
52
|
+
kind: InvitationKind,
|
|
53
|
+
key,
|
|
54
|
+
uid,
|
|
55
|
+
oid,
|
|
56
|
+
email,
|
|
57
|
+
grantType,
|
|
58
|
+
token,
|
|
59
|
+
expiresAt,
|
|
60
|
+
status,
|
|
61
|
+
createdAt,
|
|
62
|
+
updatedAt,
|
|
63
|
+
};
|
|
64
|
+
if (input.name) {
|
|
65
|
+
result.name = input.name;
|
|
66
|
+
}
|
|
67
|
+
if (input.token) {
|
|
68
|
+
result.token = input.token;
|
|
69
|
+
}
|
|
70
|
+
if (input.expiresAt) {
|
|
71
|
+
result.expiresAt = input.expiresAt;
|
|
72
|
+
}
|
|
73
|
+
if (input.respondedAt) {
|
|
74
|
+
result.respondedAt = input.respondedAt;
|
|
75
|
+
}
|
|
76
|
+
if (input.status) {
|
|
77
|
+
result.status = input.status;
|
|
78
|
+
}
|
|
79
|
+
if (input.deleted) {
|
|
80
|
+
result.deleted = input.deleted;
|
|
81
|
+
result.deletedInfo = input.deletedInfo;
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
constructor(input) {
|
|
86
|
+
const init = Invitation.createSchema(input);
|
|
87
|
+
this.kind = InvitationKind;
|
|
88
|
+
this.key = init.key;
|
|
89
|
+
this.uid = init.uid;
|
|
90
|
+
this.oid = init.oid;
|
|
91
|
+
this.email = init.email;
|
|
92
|
+
this.name = init.name;
|
|
93
|
+
this.token = init.token;
|
|
94
|
+
this.expiresAt = init.expiresAt;
|
|
95
|
+
this.respondedAt = init.respondedAt;
|
|
96
|
+
this.status = init.status;
|
|
97
|
+
this.grantType = init.grantType;
|
|
98
|
+
this.deleted = init.deleted || false;
|
|
99
|
+
this.deletedInfo = init.deletedInfo;
|
|
100
|
+
this.createdAt = init.createdAt;
|
|
101
|
+
this.updatedAt = init.updatedAt;
|
|
102
|
+
}
|
|
103
|
+
toJSON() {
|
|
104
|
+
const result = {
|
|
105
|
+
kind: this.kind,
|
|
106
|
+
key: this.key,
|
|
107
|
+
uid: this.uid,
|
|
108
|
+
oid: this.oid,
|
|
109
|
+
email: this.email,
|
|
110
|
+
token: this.token,
|
|
111
|
+
expiresAt: this.expiresAt,
|
|
112
|
+
status: this.status,
|
|
113
|
+
grantType: this.grantType,
|
|
114
|
+
deleted: this.deleted,
|
|
115
|
+
createdAt: this.createdAt,
|
|
116
|
+
updatedAt: this.updatedAt,
|
|
117
|
+
};
|
|
118
|
+
if (this.name) {
|
|
119
|
+
result.name = this.name;
|
|
120
|
+
}
|
|
121
|
+
if (this.respondedAt) {
|
|
122
|
+
result.respondedAt = this.respondedAt;
|
|
123
|
+
}
|
|
124
|
+
if (this.deletedInfo) {
|
|
125
|
+
result.deletedInfo = { ...this.deletedInfo };
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Retrieves the patch operations for this invitation.
|
|
131
|
+
* This method builds a JSON Patch representation of the invitation,
|
|
132
|
+
* which can be used to update the invitation in a database or API.
|
|
133
|
+
*
|
|
134
|
+
* Use one of the `set*` methods to modify the invitation before calling this method.
|
|
135
|
+
*
|
|
136
|
+
* @returns An array of patch operations.
|
|
137
|
+
* If no changes have been made, it returns an empty array.
|
|
138
|
+
*/
|
|
139
|
+
getPatch() {
|
|
140
|
+
if (!this.#builder) {
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
return this.builder.build();
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Sets the name of the user to whom the invitation is sent.
|
|
147
|
+
* If the name is the same as the current name, no operation is performed.
|
|
148
|
+
*
|
|
149
|
+
* @param name The name to set. If undefined, it will be removed.
|
|
150
|
+
*/
|
|
151
|
+
setName(name) {
|
|
152
|
+
if (name === this.name) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const hasName = !!this.name;
|
|
156
|
+
if (hasName && !name) {
|
|
157
|
+
this.builder.remove('/name');
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
// The add method handles both adding and replacing
|
|
161
|
+
this.builder.add('/name', name);
|
|
162
|
+
}
|
|
163
|
+
this.name = name;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Sets the expiration timestamp of the invitation.
|
|
167
|
+
* @param expiresAt The timestamp when the invitation expires.
|
|
168
|
+
* If the expiresAt is the same as the current expiresAt, no operation is performed.
|
|
169
|
+
*/
|
|
170
|
+
setExpiresAt(expiresAt) {
|
|
171
|
+
if (this.expiresAt !== expiresAt) {
|
|
172
|
+
this.builder.replace('/expiresAt', expiresAt);
|
|
173
|
+
this.expiresAt = expiresAt;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Sets the grant type of the user in the organization.
|
|
178
|
+
*/
|
|
179
|
+
setGrantType(grantType) {
|
|
180
|
+
if (this.grantType !== grantType) {
|
|
181
|
+
this.builder.replace('/grantType', grantType);
|
|
182
|
+
this.grantType = grantType;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=Invitation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Invitation.js","sourceRoot":"","sources":["../../../../src/models/store/Invitation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,c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AAS,CAAC,CAAA;YAC7C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC5B,CAAC;IACH,CAAC;CACF","sourcesContent":["import { nanoid } from 'nanoid'\nimport { InvitationKind } from '../kinds.js'\nimport type { IDeletion } from './Deletion.js'\nimport type { UserOrganizationGrantType } from './Organization.js'\nimport type { Operation } from '@api-client/json/types.js'\nimport { Builder } from '@api-client/json/patch/builder.js'\n\n/**\n * The status of an invitation.\n * - `pending`: The invitation has been sent but not yet responded to.\n * - `accepted`: The invitation has been accepted by the user.\n * - `declined`: The invitation has been declined by the user.\n */\nexport type InvitationStatus = 'pending' | 'accepted' | 'declined'\n\n/**\n * The schema for an invitation.\n * This defines the structure of an invitation object in the system.\n */\nexport interface InvitationSchema {\n /**\n * The kind of the invitation.\n */\n kind: typeof InvitationKind\n /**\n * The database ID of the invitation.\n */\n key: string\n /**\n * The user ID of the user who sent the invitation.\n */\n uid: string\n /**\n * The organization ID to which the invitation belongs.\n */\n oid: string\n /**\n * The email address of the user to whom the invitation is sent.\n */\n email: string\n /**\n * The name of the user to whom the invitation is sent.\n * This is optional and can be empty if the user is not known.\n */\n name?: string\n /**\n * The token used to respond to the invitation.\n */\n token: string\n /**\n * The timestamp when the invitation expires.\n * This is used to determine if the invitation is still valid.\n */\n expiresAt: number\n /**\n * The timestamp when the invitation was responded to.\n * This is set when the user accepts or declines the invitation.\n */\n respondedAt?: number\n /**\n * The status of the invitation.\n */\n status: InvitationStatus\n /**\n * The grant type the user will have in the organization if they accept the invitation.\n */\n grantType: UserOrganizationGrantType\n /**\n * Whether the file object is deleted.\n */\n deleted?: boolean\n /**\n * The information about the delete information.\n * Always set when the `delete` is true.\n */\n deletedInfo?: IDeletion\n /**\n * The timestamp when the invitation was created.\n */\n createdAt: number\n /**\n * The timestamp when the invitation was last updated.\n */\n updatedAt: number\n}\n\n/**\n * Represents an invitation to join an organization.\n * This class implements the `InvitationSchema` interface and provides methods to create and manipulate invitations.\n */\nexport class Invitation implements InvitationSchema {\n kind: typeof InvitationKind\n key: string\n uid: string\n oid: string\n email: string\n name: string | undefined\n token: string\n expiresAt: number\n respondedAt: number | undefined\n status: InvitationStatus\n grantType: UserOrganizationGrantType\n deleted: boolean\n deletedInfo: IDeletion | undefined\n createdAt: number\n updatedAt: number\n\n #builder?: Builder<InvitationSchema>\n\n /**\n * The patch builder for this invitation.\n */\n get builder(): Builder<InvitationSchema> {\n if (!this.#builder) {\n this.#builder = new Builder(this.toJSON())\n }\n return this.#builder\n }\n\n /**\n * Creates a full invitation schema with defaults.\n *\n * @param input The partial invitation schema.\n * @returns The invitation schema.\n */\n static createSchema(input: Partial<InvitationSchema> = {}): InvitationSchema {\n const {\n key = nanoid(),\n email,\n oid,\n grantType,\n uid = '',\n updatedAt = 0,\n createdAt = 0,\n expiresAt = 0,\n status = 'pending',\n token = '',\n } = input\n if (!email) {\n throw new Error('Email is required to create an invitation schema.')\n }\n if (!oid) {\n throw new Error('Organization ID is required to create an invitation schema.')\n }\n if (!grantType) {\n throw new Error('Grant type is required to create an invitation schema.')\n }\n const result: InvitationSchema = {\n kind: InvitationKind,\n key,\n uid,\n oid,\n email,\n grantType,\n token,\n expiresAt,\n status,\n createdAt,\n updatedAt,\n }\n if (input.name) {\n result.name = input.name\n }\n if (input.token) {\n result.token = input.token\n }\n if (input.expiresAt) {\n result.expiresAt = input.expiresAt\n }\n if (input.respondedAt) {\n result.respondedAt = input.respondedAt\n }\n if (input.status) {\n result.status = input.status\n }\n if (input.deleted) {\n result.deleted = input.deleted\n result.deletedInfo = input.deletedInfo\n }\n return result\n }\n\n constructor(input?: Partial<InvitationSchema>) {\n const init: InvitationSchema = Invitation.createSchema(input)\n this.kind = InvitationKind\n this.key = init.key\n this.uid = init.uid\n this.oid = init.oid\n this.email = init.email\n this.name = init.name\n this.token = init.token\n this.expiresAt = init.expiresAt\n this.respondedAt = init.respondedAt\n this.status = init.status\n this.grantType = init.grantType\n this.deleted = init.deleted || false\n this.deletedInfo = init.deletedInfo\n this.createdAt = init.createdAt\n this.updatedAt = init.updatedAt\n }\n\n toJSON(): InvitationSchema {\n const result: InvitationSchema = {\n kind: this.kind,\n key: this.key,\n uid: this.uid,\n oid: this.oid,\n email: this.email,\n token: this.token,\n expiresAt: this.expiresAt,\n status: this.status,\n grantType: this.grantType,\n deleted: this.deleted,\n createdAt: this.createdAt,\n updatedAt: this.updatedAt,\n }\n if (this.name) {\n result.name = this.name\n }\n if (this.respondedAt) {\n result.respondedAt = this.respondedAt\n }\n if (this.deletedInfo) {\n result.deletedInfo = { ...this.deletedInfo }\n }\n return result\n }\n\n /**\n * Retrieves the patch operations for this invitation.\n * This method builds a JSON Patch representation of the invitation,\n * which can be used to update the invitation in a database or API.\n *\n * Use one of the `set*` methods to modify the invitation before calling this method.\n *\n * @returns An array of patch operations.\n * If no changes have been made, it returns an empty array.\n */\n getPatch(): Operation[] {\n if (!this.#builder) {\n return []\n }\n return this.builder.build()\n }\n\n /**\n * Sets the name of the user to whom the invitation is sent.\n * If the name is the same as the current name, no operation is performed.\n *\n * @param name The name to set. If undefined, it will be removed.\n */\n setName(name?: string): void {\n if (name === this.name) {\n return\n }\n const hasName = !!this.name\n if (hasName && !name) {\n this.builder.remove('/name')\n } else {\n // The add method handles both adding and replacing\n this.builder.add('/name', name)\n }\n this.name = name\n }\n\n /**\n * Sets the expiration timestamp of the invitation.\n * @param expiresAt The timestamp when the invitation expires.\n * If the expiresAt is the same as the current expiresAt, no operation is performed.\n */\n setExpiresAt(expiresAt: number): void {\n if (this.expiresAt !== expiresAt) {\n this.builder.replace('/expiresAt', expiresAt)\n this.expiresAt = expiresAt\n }\n }\n\n /**\n * Sets the grant type of the user in the organization.\n */\n setGrantType(grantType: UserOrganizationGrantType): void {\n if (this.grantType !== grantType) {\n this.builder.replace('/grantType', grantType)\n this.grantType = grantType\n }\n }\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { IDeletion } from './Deletion.js';
|
|
2
|
-
|
|
3
|
-
export type UserOrganizationGrantType = 'owner' | '
|
|
2
|
+
import { OrganizationKind } from '../kinds.js';
|
|
3
|
+
export type UserOrganizationGrantType = 'owner' | 'manager' | 'editor' | 'viewer';
|
|
4
4
|
/**
|
|
5
5
|
* In the system the user identity represents registration information associated with a specific identity provider.
|
|
6
6
|
* This association allows the user to use different identity providers that map to the same user, as long as the
|
|
7
7
|
* email stays consistent.
|
|
8
8
|
*/
|
|
9
9
|
export interface IOrganization {
|
|
10
|
-
kind: typeof
|
|
10
|
+
kind: typeof OrganizationKind;
|
|
11
11
|
/**
|
|
12
12
|
* The database ID
|
|
13
13
|
*/
|
|
@@ -40,7 +40,7 @@ export interface IOrganization {
|
|
|
40
40
|
grantType: UserOrganizationGrantType;
|
|
41
41
|
}
|
|
42
42
|
export declare class Organization implements IOrganization {
|
|
43
|
-
kind: typeof
|
|
43
|
+
kind: typeof OrganizationKind;
|
|
44
44
|
key: string;
|
|
45
45
|
name: string;
|
|
46
46
|
createdBy: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Organization.d.ts","sourceRoot":"","sources":["../../../../src/models/store/Organization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"Organization.d.ts","sourceRoot":"","sources":["../../../../src/models/store/Organization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,MAAM,MAAM,yBAAyB,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEjF;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,gBAAgB,CAAA;IAC7B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB;;;OAGG;IACH,SAAS,EAAE,yBAAyB,CAAA;CACrC;AAED,qBAAa,YAAa,YAAW,aAAa;IAChD,IAAI,EAAE,OAAO,gBAAgB,CAAmB;IAChD,GAAG,SAAK;IACR,IAAI,SAAK;IACT,SAAS,SAAK;IACd,WAAW,SAAI;IACf,OAAO,UAAQ;IACf,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,SAAS,EAAE,yBAAyB,CAAW;gBAEnC,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa;IAoB1C,GAAG,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IA2B9B;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAQ9C,MAAM,IAAI,aAAa;CAexB"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { nanoid } from 'nanoid';
|
|
2
|
-
|
|
2
|
+
import { OrganizationKind } from '../kinds.js';
|
|
3
3
|
export class Organization {
|
|
4
|
-
kind =
|
|
4
|
+
kind = OrganizationKind;
|
|
5
5
|
key = '';
|
|
6
6
|
name = '';
|
|
7
7
|
createdBy = '';
|
|
8
8
|
createdDate = 0;
|
|
9
9
|
deleted = false;
|
|
10
10
|
deletedInfo;
|
|
11
|
-
grantType = '
|
|
11
|
+
grantType = 'viewer';
|
|
12
12
|
constructor(input) {
|
|
13
13
|
let init;
|
|
14
14
|
if (typeof input === 'string') {
|
|
@@ -19,13 +19,13 @@ export class Organization {
|
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
21
|
init = {
|
|
22
|
-
kind:
|
|
22
|
+
kind: OrganizationKind,
|
|
23
23
|
key: nanoid(),
|
|
24
24
|
name: '',
|
|
25
25
|
createdBy: '',
|
|
26
26
|
createdDate: Date.now(),
|
|
27
27
|
deleted: false,
|
|
28
|
-
grantType: '
|
|
28
|
+
grantType: 'viewer',
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
this.new(init);
|
|
@@ -34,8 +34,8 @@ export class Organization {
|
|
|
34
34
|
if (!Organization.isOrganization(init)) {
|
|
35
35
|
throw new Error(`Not an Organization.`);
|
|
36
36
|
}
|
|
37
|
-
const { key = nanoid(), name, createdBy, createdDate = Date.now(), deleted = false, deletedInfo, grantType = '
|
|
38
|
-
this.kind =
|
|
37
|
+
const { key = nanoid(), name, createdBy, createdDate = Date.now(), deleted = false, deletedInfo, grantType = 'viewer', } = init;
|
|
38
|
+
this.kind = OrganizationKind;
|
|
39
39
|
this.key = key;
|
|
40
40
|
this.name = name;
|
|
41
41
|
this.createdBy = createdBy;
|
|
@@ -54,14 +54,14 @@ export class Organization {
|
|
|
54
54
|
*/
|
|
55
55
|
static isOrganization(input) {
|
|
56
56
|
const typed = input;
|
|
57
|
-
if (!input || typed.kind !==
|
|
57
|
+
if (!input || typed.kind !== OrganizationKind) {
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
60
60
|
return true;
|
|
61
61
|
}
|
|
62
62
|
toJSON() {
|
|
63
63
|
const result = {
|
|
64
|
-
kind:
|
|
64
|
+
kind: OrganizationKind,
|
|
65
65
|
key: this.key,
|
|
66
66
|
name: this.name,
|
|
67
67
|
createdBy: this.createdBy,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Organization.js","sourceRoot":"","sources":["../../../../src/models/store/Organization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"Organization.js","sourceRoot":"","sources":["../../../../src/models/store/Organization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AA2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AG,GAAG,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAChC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;QAC9B,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,KAAc;QAClC,MAAM,KAAK,GAAG,KAAsB,CAAA;QACpC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YAC9C,OAAO,KAAK,CAAA;QACd,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM;QACJ,MAAM,MAAM,GAAkB;YAC5B,IAAI,EAAE,gBAAgB;YACtB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAA;QACD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QACvC,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { nanoid } from 'nanoid'\nimport type { IDeletion } from './Deletion.js'\nimport { OrganizationKind } from '../kinds.js'\n\nexport type UserOrganizationGrantType = 'owner' | 'manager' | 'editor' | 'viewer'\n\n/**\n * In the system the user identity represents registration information associated with a specific identity provider.\n * This association allows the user to use different identity providers that map to the same user, as long as the\n * email stays consistent.\n */\nexport interface IOrganization {\n kind: typeof OrganizationKind\n /**\n * The database ID\n */\n key: string\n /**\n * The organization name\n */\n name: string\n /**\n * The key of the user that created the organization.\n */\n createdBy: string\n /**\n * The timestamp when the organization was created.\n */\n createdDate: number\n /**\n * Whether the organization object is deleted.\n */\n deleted?: boolean\n /**\n * The information about the delete information.\n * Always set when the `delete` is true.\n */\n deletedInfo?: IDeletion\n /**\n * The grant type to the organization the **current user** has.\n * By nature, it's a dynamic field populated by the data store.\n */\n grantType: UserOrganizationGrantType\n}\n\nexport class Organization implements IOrganization {\n kind: typeof OrganizationKind = OrganizationKind\n key = ''\n name = ''\n createdBy = ''\n createdDate = 0\n deleted = false\n deletedInfo?: IDeletion\n grantType: UserOrganizationGrantType = 'viewer'\n\n constructor(input?: string | IOrganization) {\n let init: IOrganization\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: OrganizationKind,\n key: nanoid(),\n name: '',\n createdBy: '',\n createdDate: Date.now(),\n deleted: false,\n grantType: 'viewer',\n }\n }\n this.new(init)\n }\n\n new(init: IOrganization): void {\n if (!Organization.isOrganization(init)) {\n throw new Error(`Not an Organization.`)\n }\n const {\n key = nanoid(),\n name,\n createdBy,\n createdDate = Date.now(),\n deleted = false,\n deletedInfo,\n grantType = 'viewer',\n } = init\n this.kind = OrganizationKind\n this.key = key\n this.name = name\n this.createdBy = createdBy\n this.createdDate = createdDate\n this.deleted = deleted\n this.grantType = grantType\n if (deletedInfo) {\n this.deletedInfo = deletedInfo\n } else {\n this.deletedInfo = undefined\n }\n }\n\n /**\n * Checks whether the input is a definition of an user organization.\n */\n static isOrganization(input: unknown): boolean {\n const typed = input as IOrganization\n if (!input || typed.kind !== OrganizationKind) {\n return false\n }\n return true\n }\n\n toJSON(): IOrganization {\n const result: IOrganization = {\n kind: OrganizationKind,\n key: this.key,\n name: this.name,\n createdBy: this.createdBy,\n createdDate: this.createdDate,\n deleted: this.deleted,\n grantType: this.grantType,\n }\n if (this.deletedInfo) {\n result.deletedInfo = this.deletedInfo\n }\n return result\n }\n}\n"]}
|
|
@@ -9,14 +9,14 @@ export class HttpWeb extends Http {
|
|
|
9
9
|
* @returns The response info.
|
|
10
10
|
*/
|
|
11
11
|
async get(url, opts = {}) {
|
|
12
|
-
const { method = 'GET', headers = {}, token } = opts;
|
|
13
|
-
const
|
|
12
|
+
const { method = 'GET', headers = {}, token = this.sdk.token } = opts;
|
|
13
|
+
const requestHeaders = new Headers({ ...headers });
|
|
14
14
|
if (token) {
|
|
15
|
-
|
|
15
|
+
requestHeaders.append('Authorization', `Bearer ${token}`);
|
|
16
16
|
}
|
|
17
17
|
const init = {
|
|
18
18
|
method,
|
|
19
|
-
headers:
|
|
19
|
+
headers: requestHeaders.toJSON(),
|
|
20
20
|
redirect: 'follow',
|
|
21
21
|
credentials: 'include',
|
|
22
22
|
mode: 'cors',
|
|
@@ -41,7 +41,7 @@ export class HttpWeb extends Http {
|
|
|
41
41
|
return result;
|
|
42
42
|
}
|
|
43
43
|
async post(url, opts = {}) {
|
|
44
|
-
const { method = 'POST', headers = {}, token } = opts;
|
|
44
|
+
const { method = 'POST', headers = {}, token = this.sdk.token } = opts;
|
|
45
45
|
const requestHeaders = new Headers({ ...headers });
|
|
46
46
|
if (token) {
|
|
47
47
|
requestHeaders.append('Authorization', `Bearer ${token}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpWeb.js","sourceRoot":"","sources":["../../../../src/runtime/store/HttpWeb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAEtD,MAAM,OAAO,OAAQ,SAAQ,IAAI;IAC/B;;;;;;OAMG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,OAA6B,EAAE;QACpD,MAAM,EAA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,MAAM,eAAe,GAAG,IAAI,OAAO,EAAE,CAAA;QACrC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAa,EAAE,GAAW,EAAE,EAAE;YACtD,eAAe,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACpC,CAAC,CAAC,CAAA;QAEF,MAAM,MAAM,GAAmB;YAC7B,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,OAAO,EAAE,eAAe;YACxB,IAAI;SACL,CAAA;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,OAA6B,EAAE;QAChD,MAAM,OAAO,GAAyB,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;QAClE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAChC,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,OAA6B,EAAE;QAC9C,MAAM,OAAO,GAAyB,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;QAChE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAChC,CAAC;IAED,MAAM,CAAC,GAAW,EAAE,OAA6B,EAAE;QACjD,MAAM,OAAO,GAAyB,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAA;QACnE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAChC,CAAC;CACF","sourcesContent":["import { Http } from './Http.js'\nimport { IStoreRequestOptions, IStoreResponse } from './SdkBase.js'\nimport { Headers } from '../../lib/headers/Headers.js'\n\nexport class HttpWeb extends Http {\n /**\n * Performs the GET request.\n *\n * @param url The request URL\n * @param opts The request options\n * @returns The response info.\n */\n async get(url: string, opts: IStoreRequestOptions = {}): Promise<IStoreResponse> {\n const { method = 'GET', headers = {}, token = this.sdk.token } = opts\n const requestHeaders = new Headers({ ...headers })\n if (token) {\n requestHeaders.append('Authorization', `Bearer ${token}`)\n }\n const init: RequestInit = {\n method,\n headers: requestHeaders.toJSON(),\n redirect: 'follow',\n credentials: 'include',\n mode: 'cors',\n }\n const response = await fetch(url, init)\n let body: string | undefined\n try {\n body = await response.text()\n } catch {\n // ...\n }\n\n const responseHeaders = new Headers()\n response.headers.forEach((value: string, key: string) => {\n responseHeaders.append(key, value)\n })\n\n const result: IStoreResponse = {\n status: response.status,\n headers: responseHeaders,\n body,\n }\n return result\n }\n\n async post(url: string, opts: IStoreRequestOptions = {}): Promise<IStoreResponse> {\n const { method = 'POST', headers = {}, token = this.sdk.token } = opts\n const requestHeaders = new Headers({ ...headers })\n if (token) {\n requestHeaders.append('Authorization', `Bearer ${token}`)\n }\n if (!requestHeaders.has('Content-Type')) {\n requestHeaders.append('Content-Type', 'application/json')\n }\n const init: RequestInit = {\n method,\n headers: requestHeaders.toJSON(),\n redirect: 'follow',\n credentials: 'include',\n }\n if (opts.body) {\n init.body = opts.body.toString()\n }\n const response = await fetch(url, init)\n let body: string | undefined\n try {\n body = await response.text()\n } catch {\n // ...\n }\n\n const responseHeaders = new Headers()\n response.headers.forEach((value: string, key: string) => {\n responseHeaders.append(key, value)\n })\n\n const result: IStoreResponse = {\n status: response.status,\n headers: responseHeaders,\n body,\n }\n return result\n }\n\n patch(url: string, opts: IStoreRequestOptions = {}): Promise<IStoreResponse> {\n const options: IStoreRequestOptions = { ...opts, method: 'PATCH' }\n return this.post(url, options)\n }\n\n put(url: string, opts: IStoreRequestOptions = {}): Promise<IStoreResponse> {\n const options: IStoreRequestOptions = { ...opts, method: 'PUT' }\n return this.post(url, options)\n }\n\n delete(url: string, opts: IStoreRequestOptions = {}): Promise<IStoreResponse> {\n const options: IStoreRequestOptions = { ...opts, method: 'DELETE' }\n return this.post(url, options)\n }\n}\n"]}
|
|
@@ -1,11 +1,67 @@
|
|
|
1
1
|
import { SdkBase, SdkOptions } from './SdkBase.js';
|
|
2
|
-
import { ContextListResult } from '../../events/BaseEvents.js';
|
|
3
|
-
import { IOrganization } from '../../models/store/Organization.js';
|
|
2
|
+
import type { ContextListResult } from '../../events/BaseEvents.js';
|
|
3
|
+
import type { IOrganization, UserOrganizationGrantType } from '../../models/store/Organization.js';
|
|
4
|
+
import type { InvitationSchema } from '../../models/store/Invitation.js';
|
|
5
|
+
import type { PatchInfo } from '../../patch/types.js';
|
|
4
6
|
export declare class OrganizationsSdk extends SdkBase {
|
|
5
7
|
/**
|
|
6
8
|
* Lists all user organizations.
|
|
7
9
|
*/
|
|
8
10
|
list(request?: SdkOptions): Promise<ContextListResult<IOrganization>>;
|
|
9
11
|
create(orgName: string, request?: SdkOptions): Promise<IOrganization>;
|
|
12
|
+
/**
|
|
13
|
+
* Lists all invitations for a given organization.
|
|
14
|
+
* @param oid The organization ID.
|
|
15
|
+
* @param request The request options.
|
|
16
|
+
* @returns A promise that resolves to a list of invitations.
|
|
17
|
+
*/
|
|
18
|
+
listInvitations(oid: string, request?: SdkOptions): Promise<ContextListResult<InvitationSchema>>;
|
|
19
|
+
/**
|
|
20
|
+
* Creates an invitation for a user to join an organization.
|
|
21
|
+
* @param oid The organization ID.
|
|
22
|
+
* @param email The email address of the user to invite.
|
|
23
|
+
* @param grant_type The type of grant for the user.
|
|
24
|
+
* @param name The name of the user (optional).
|
|
25
|
+
* @param request The request options.
|
|
26
|
+
* @returns A promise that resolves to the created invitation.
|
|
27
|
+
*/
|
|
28
|
+
createInvitation(oid: string, email: string, grant_type: UserOrganizationGrantType, name?: string, request?: SdkOptions): Promise<InvitationSchema>;
|
|
29
|
+
/**
|
|
30
|
+
* Finds an invitation by its token.
|
|
31
|
+
* @param oid The organization ID.
|
|
32
|
+
* @param token The invitation token.
|
|
33
|
+
* @param request The request options.
|
|
34
|
+
* @returns A promise that resolves to the found invitation.
|
|
35
|
+
*/
|
|
36
|
+
findInvitationByToken(oid: string, token: string, request?: SdkOptions): Promise<InvitationSchema>;
|
|
37
|
+
/**
|
|
38
|
+
* Declines an invitation.
|
|
39
|
+
* @param oid The organization ID.
|
|
40
|
+
* @param id The invitation ID.
|
|
41
|
+
* @param request The request options.
|
|
42
|
+
* @returns A promise that resolves when the invitation is declined.
|
|
43
|
+
*/
|
|
44
|
+
declineInvitation(oid: string, id: string, request?: SdkOptions): Promise<InvitationSchema>;
|
|
45
|
+
/**
|
|
46
|
+
* Soft-deletes an invitation.
|
|
47
|
+
* @param oid The organization ID.
|
|
48
|
+
* @param id The invitation ID.
|
|
49
|
+
* @param request The request options.
|
|
50
|
+
* @returns A promise that resolves to the deleted invitation.
|
|
51
|
+
*/
|
|
52
|
+
deleteInvitation(oid: string, id: string, request?: SdkOptions): Promise<InvitationSchema>;
|
|
53
|
+
/**
|
|
54
|
+
* Patches an invitation. The server performs the patch validation.
|
|
55
|
+
* The API only allows to patch some of the invitation properties:
|
|
56
|
+
* - name
|
|
57
|
+
* - expires_at
|
|
58
|
+
* - grant_type
|
|
59
|
+
* @param oid The organization ID.
|
|
60
|
+
* @param id The invitation ID.
|
|
61
|
+
* @param info The patch information.
|
|
62
|
+
* @param request The request options.
|
|
63
|
+
* @returns A promise that resolves to the patched invitation.
|
|
64
|
+
*/
|
|
65
|
+
patchInvitation(oid: string, id: string, info: PatchInfo, request?: SdkOptions): Promise<InvitationSchema>;
|
|
10
66
|
}
|
|
11
67
|
//# sourceMappingURL=OrganizationsSdk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrganizationsSdk.d.ts","sourceRoot":"","sources":["../../../../src/runtime/store/OrganizationsSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAKP,UAAU,EACX,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"OrganizationsSdk.d.ts","sourceRoot":"","sources":["../../../../src/runtime/store/OrganizationsSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OA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