@api-client/core 0.12.7 → 0.12.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/build/src/browser.d.ts +3 -2
  2. package/build/src/browser.d.ts.map +1 -1
  3. package/build/src/browser.js +2 -1
  4. package/build/src/browser.js.map +1 -1
  5. package/build/src/index.d.ts +3 -2
  6. package/build/src/index.d.ts.map +1 -1
  7. package/build/src/index.js +2 -1
  8. package/build/src/index.js.map +1 -1
  9. package/build/src/mocking/lib/User.d.ts.map +1 -1
  10. package/build/src/mocking/lib/User.js +1 -0
  11. package/build/src/mocking/lib/User.js.map +1 -1
  12. package/build/src/models/kinds.d.ts +2 -0
  13. package/build/src/models/kinds.d.ts.map +1 -1
  14. package/build/src/models/kinds.js +2 -0
  15. package/build/src/models/kinds.js.map +1 -1
  16. package/build/src/models/store/Invitation.d.ts +146 -0
  17. package/build/src/models/store/Invitation.d.ts.map +1 -0
  18. package/build/src/models/store/Invitation.js +186 -0
  19. package/build/src/models/store/Invitation.js.map +1 -0
  20. package/build/src/models/store/Organization.d.ts +4 -4
  21. package/build/src/models/store/Organization.d.ts.map +1 -1
  22. package/build/src/models/store/Organization.js +9 -9
  23. package/build/src/models/store/Organization.js.map +1 -1
  24. package/build/src/models/store/User.d.ts +14 -0
  25. package/build/src/models/store/User.d.ts.map +1 -1
  26. package/build/src/models/store/User.js.map +1 -1
  27. package/build/src/runtime/store/HttpWeb.js +5 -5
  28. package/build/src/runtime/store/HttpWeb.js.map +1 -1
  29. package/build/src/runtime/store/OrganizationsSdk.d.ts +77 -2
  30. package/build/src/runtime/store/OrganizationsSdk.d.ts.map +1 -1
  31. package/build/src/runtime/store/OrganizationsSdk.js +278 -3
  32. package/build/src/runtime/store/OrganizationsSdk.js.map +1 -1
  33. package/build/src/runtime/store/RouteBuilder.d.ts +15 -2
  34. package/build/src/runtime/store/RouteBuilder.d.ts.map +1 -1
  35. package/build/src/runtime/store/RouteBuilder.js +33 -6
  36. package/build/src/runtime/store/RouteBuilder.js.map +1 -1
  37. package/build/src/runtime/store/Sdk.d.ts +1 -1
  38. package/build/src/runtime/store/Sdk.d.ts.map +1 -1
  39. package/build/src/runtime/store/Sdk.js +1 -1
  40. package/build/src/runtime/store/Sdk.js.map +1 -1
  41. package/build/src/runtime/store/SdkBase.d.ts +2 -2
  42. package/build/src/runtime/store/SdkBase.d.ts.map +1 -1
  43. package/build/src/runtime/store/SdkBase.js +2 -2
  44. package/build/src/runtime/store/SdkBase.js.map +1 -1
  45. package/build/src/runtime/store/UsersSdk.d.ts +2 -0
  46. package/build/src/runtime/store/UsersSdk.d.ts.map +1 -1
  47. package/build/src/runtime/store/UsersSdk.js +6 -0
  48. package/build/src/runtime/store/UsersSdk.js.map +1 -1
  49. package/eslint.config.js +6 -5
  50. package/package.json +23 -5
  51. package/src/mocking/lib/User.ts +1 -0
  52. package/src/models/kinds.ts +2 -0
  53. package/src/models/store/Invitation.ts +287 -0
  54. package/src/models/store/Organization.ts +11 -12
  55. package/src/models/store/User.ts +16 -0
  56. package/src/runtime/store/HttpWeb.ts +5 -5
  57. package/src/runtime/store/OrganizationsSdk.ts +293 -5
  58. package/src/runtime/store/RouteBuilder.ts +42 -8
  59. package/src/runtime/store/Sdk.ts +1 -1
  60. package/src/runtime/store/SdkBase.ts +2 -2
  61. package/src/runtime/store/UsersSdk.ts +6 -0
  62. package/tests/unit/models/store/Invitation.spec.ts +223 -0
@@ -0,0 +1,146 @@
1
+ import { InvitationKind } from '../kinds.js';
2
+ import type { IDeletion } from './Deletion.js';
3
+ import type { UserOrganizationGrantType } from './Organization.js';
4
+ import type { Operation } from '@api-client/json/types.js';
5
+ import { Builder } from '@api-client/json/patch/builder.js';
6
+ /**
7
+ * The status of an invitation.
8
+ * - `pending`: The invitation has been sent but not yet responded to.
9
+ * - `accepted`: The invitation has been accepted by the user.
10
+ * - `declined`: The invitation has been declined by the user.
11
+ */
12
+ export type InvitationStatus = 'pending' | 'accepted' | 'declined';
13
+ /**
14
+ * The schema for an invitation.
15
+ * This defines the structure of an invitation object in the system.
16
+ */
17
+ export interface InvitationSchema {
18
+ /**
19
+ * The kind of the invitation.
20
+ */
21
+ kind: typeof InvitationKind;
22
+ /**
23
+ * The database ID of the invitation.
24
+ */
25
+ key: string;
26
+ /**
27
+ * The user ID of the user who sent the invitation.
28
+ */
29
+ uid: string;
30
+ /**
31
+ * The organization ID to which the invitation belongs.
32
+ */
33
+ oid: string;
34
+ /**
35
+ * The email address of the user to whom the invitation is sent.
36
+ */
37
+ email: string;
38
+ /**
39
+ * The name of the user to whom the invitation is sent.
40
+ * This is optional and can be empty if the user is not known.
41
+ */
42
+ name?: string;
43
+ /**
44
+ * The token used to respond to the invitation.
45
+ */
46
+ token: string;
47
+ /**
48
+ * The timestamp when the invitation expires.
49
+ * This is used to determine if the invitation is still valid.
50
+ */
51
+ expiresAt: number;
52
+ /**
53
+ * The timestamp when the invitation was responded to.
54
+ * This is set when the user accepts or declines the invitation.
55
+ */
56
+ respondedAt?: number;
57
+ /**
58
+ * The status of the invitation.
59
+ */
60
+ status: InvitationStatus;
61
+ /**
62
+ * The grant type the user will have in the organization if they accept the invitation.
63
+ */
64
+ grantType: UserOrganizationGrantType;
65
+ /**
66
+ * Whether the file object is deleted.
67
+ */
68
+ deleted?: boolean;
69
+ /**
70
+ * The information about the delete information.
71
+ * Always set when the `delete` is true.
72
+ */
73
+ deletedInfo?: IDeletion;
74
+ /**
75
+ * The timestamp when the invitation was created.
76
+ */
77
+ createdAt: number;
78
+ /**
79
+ * The timestamp when the invitation was last updated.
80
+ */
81
+ updatedAt: number;
82
+ }
83
+ /**
84
+ * Represents an invitation to join an organization.
85
+ * This class implements the `InvitationSchema` interface and provides methods to create and manipulate invitations.
86
+ */
87
+ export declare class Invitation implements InvitationSchema {
88
+ #private;
89
+ kind: typeof InvitationKind;
90
+ key: string;
91
+ uid: string;
92
+ oid: string;
93
+ email: string;
94
+ name: string | undefined;
95
+ token: string;
96
+ expiresAt: number;
97
+ respondedAt: number | undefined;
98
+ status: InvitationStatus;
99
+ grantType: UserOrganizationGrantType;
100
+ deleted: boolean;
101
+ deletedInfo: IDeletion | undefined;
102
+ createdAt: number;
103
+ updatedAt: number;
104
+ /**
105
+ * The patch builder for this invitation.
106
+ */
107
+ get builder(): Builder<InvitationSchema>;
108
+ /**
109
+ * Creates a full invitation schema with defaults.
110
+ *
111
+ * @param input The partial invitation schema.
112
+ * @returns The invitation schema.
113
+ */
114
+ static createSchema(input?: Partial<InvitationSchema>): InvitationSchema;
115
+ constructor(input?: Partial<InvitationSchema>);
116
+ toJSON(): InvitationSchema;
117
+ /**
118
+ * Retrieves the patch operations for this invitation.
119
+ * This method builds a JSON Patch representation of the invitation,
120
+ * which can be used to update the invitation in a database or API.
121
+ *
122
+ * Use one of the `set*` methods to modify the invitation before calling this method.
123
+ *
124
+ * @returns An array of patch operations.
125
+ * If no changes have been made, it returns an empty array.
126
+ */
127
+ getPatch(): Operation[];
128
+ /**
129
+ * Sets the name of the user to whom the invitation is sent.
130
+ * If the name is the same as the current name, no operation is performed.
131
+ *
132
+ * @param name The name to set. If undefined, it will be removed.
133
+ */
134
+ setName(name?: string): void;
135
+ /**
136
+ * Sets the expiration timestamp of the invitation.
137
+ * @param expiresAt The timestamp when the invitation expires.
138
+ * If the expiresAt is the same as the current expiresAt, no operation is performed.
139
+ */
140
+ setExpiresAt(expiresAt: number): void;
141
+ /**
142
+ * Sets the grant type of the user in the organization.
143
+ */
144
+ setGrantType(grantType: UserOrganizationGrantType): void;
145
+ }
146
+ //# sourceMappingURL=Invitation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Invitation.d.ts","sourceRoot":"","sources":["../../../../src/models/store/Invitation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,y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M,CAAA;IACjB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,MAAM,EAAE,gBAAgB,CAAA;IACxB,SAAS,EAAE,yBAAyB,CAAA;IACpC,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,SAAS,GAAG,SAAS,CAAA;IAClC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IAIjB;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAKvC;IAED;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,GAAE,OAAO,CAAC,gBAAgB,CAAM,GAAG,gBAAgB;gBAyDhE,KAAK,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAmB7C,MAAM,IAAI,gBAAgB;IA2B1B;;;;;;;;;OASG;IACH,QAAQ,IAAI,SAAS,EAAE;IAOvB;;;;;OAKG;IACH,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAc5B;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAOrC;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,yBAAyB,GAAG,IAAI;CAMzD"}
@@ -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,cAAc,EAAE,MAAM,aAAa,CAAA;AAI5C,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAA;AAiF3D;;;GAGG;AACH,MAAM,OAAO,UAAU;IACrB,IAAI,CAAuB;IAC3B,GAAG,CAAQ;IACX,GAAG,CAAQ;IACX,GAAG,CAAQ;IACX,KAAK,CAAQ;IACb,IAAI,CAAoB;IACxB,KAAK,CAAQ;IACb,SAAS,CAAQ;IACjB,WAAW,CAAoB;IAC/B,MAAM,CAAkB;IACxB,SAAS,CAA2B;IACpC,OAAO,CAAS;IAChB,WAAW,CAAuB;IAClC,SAAS,CAAQ;IACjB,SAAS,CAAQ;IAEjB,QAAQ,CAA4B;IAEpC;;OAEG;IACH,IAAI,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;QAC5C,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,QAAmC,EAAE;QACvD,MAAM,EACJ,GAAG,GAAG,MAAM,EAAE,EACd,KAAK,EACL,GAAG,EACH,SAAS,EACT,GAAG,GAAG,EAAE,EACR,SAAS,GAAG,CAAC,EACb,SAAS,GAAG,CAAC,EACb,SAAS,GAAG,CAAC,EACb,MAAM,GAAG,SAAS,EAClB,KAAK,GAAG,EAAE,GACX,GAAG,KAAK,CAAA;QACT,IAAI,CAAC,KAAK,EAAE,CAAC;YAC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AAC,YAAY,EAAE,SAAS,CAAC,CAAA;YAC7C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC5B,CAAC;IACH,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,SAAoC;QAC/C,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,SAAS,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
- export declare const Kind = "Core#Organization";
3
- export type UserOrganizationGrantType = 'owner' | 'member';
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 Kind;
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 Kind;
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;AAE9C,eAAO,MAAM,IAAI,sBAAsB,CAAA;AAEvC,MAAM,MAAM,yBAAyB,GAAG,OAAO,GAAG,QAAQ,CAAA;AAE1D;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,IAAI,CAAA;IACjB;;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,IAAI,CAAO;IACxB,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
+ {"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
- export const Kind = 'Core#Organization';
2
+ import { OrganizationKind } from '../kinds.js';
3
3
  export class Organization {
4
- kind = 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 = 'member';
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: 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: 'member',
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 = 'member', } = init;
38
- this.kind = 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 !== 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: 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;AAG/B,MAAM,CAAC,MAAM,IAAI,GAAG,mBAAmB,CAAA;AA2CvC,MAAM,OAAO,YAAY;IACvB,IAAI,GAAgB,IAAI,CAAA;IACxB,GAAG,GAAG,EAAE,CAAA;IACR,IAAI,GAAG,EAAE,CAAA;IACT,SAAS,GAAG,EAAE,CAAA;IACd,WAAW,GAAG,CAAC,CAAA;IACf,OAAO,GAAG,KAAK,CAAA;IACf,WAAW,CAAY;IACvB,SAAS,GAA8B,QAAQ,CAAA;IAE/C,YAAY,KAA8B;QACxC,IAAI,IAAmB,CAAA;QACvB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC1B,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrC,IAAI,GAAG,KAAK,CAAA;QACd,CAAC;aAAM,CAAC;YACN,IAAI,GAAG;gBACL,IAAI,EAAE,IAAI;gBACV,GAAG,EAAE,MAAM,EAAE;gBACb,IAAI,EAAE,EAAE;gBACR,SAAS,EAAE,EAAE;gBACb,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE;gBACvB,OAAO,EAAE,KAAK;gBACd,SAAS,EAAE,QAAQ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AAI;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'\n\nexport const Kind = 'Core#Organization'\n\nexport type UserOrganizationGrantType = 'owner' | 'member'\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 Kind\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 Kind = Kind\n key = ''\n name = ''\n createdBy = ''\n createdDate = 0\n deleted = false\n deletedInfo?: IDeletion\n grantType: UserOrganizationGrantType = 'member'\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: Kind,\n key: nanoid(),\n name: '',\n createdBy: '',\n createdDate: Date.now(),\n deleted: false,\n grantType: 'member',\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 = 'member',\n } = init\n this.kind = Kind\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 !== Kind) {\n return false\n }\n return true\n }\n\n toJSON(): IOrganization {\n const result: IOrganization = {\n kind: Kind,\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"]}
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;AA2C9C,MAAM,OAAO,YAAY;IACvB,IAAI,GAA4B,gBAAgB,CAAA;IAChD,GAAG,GAAG,EAAE,CAAA;IACR,IAAI,GAAG,EAAE,CAAA;IACT,SAAS,GAAG,EAAE,CAAA;IACd,WAAW,GAAG,CAAC,CAAA;IACf,OAAO,GAAG,KAAK,CAAA;IACf,WAAW,CAAY;IACvB,SAAS,GAA8B,QAAQ,CAAA;IAE/C,YAAY,KAA8B;QACxC,IAAI,IAAmB,CAAA;QACvB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC1B,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrC,IAAI,GAAG,KAAK,CAAA;QACd,CAAC;aAA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,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"]}
@@ -1,3 +1,4 @@
1
+ import type { UserOrganizationGrantType } from './Organization.js';
1
2
  export interface IEmail {
2
3
  /**
3
4
  * When available the email of the user.
@@ -20,6 +21,7 @@ export interface IUserPicture {
20
21
  data?: string;
21
22
  }
22
23
  export declare const Kind = "Core#User";
24
+ export type UserStatus = 'active' | 'deleted' | 'suspended' | 'pending';
23
25
  /**
24
26
  * Represents a user in the system.
25
27
  * This can be embedded in various situations like project's revision history,
@@ -60,6 +62,7 @@ export interface IUser {
60
62
  provider?: unknown;
61
63
  /**
62
64
  * Whether the user is deleted from the system.
65
+ * @deprecated Use `status` instead.
63
66
  */
64
67
  deleted?: boolean;
65
68
  /**
@@ -70,5 +73,16 @@ export interface IUser {
70
73
  * The id of the user that deleted the user.
71
74
  */
72
75
  deletingUser?: string;
76
+ /**
77
+ * The status of the user.
78
+ * May not be populated in all cases.
79
+ * @default 'active'
80
+ */
81
+ status?: UserStatus;
82
+ /**
83
+ * Populated when the user object is considered in the context of an organization.
84
+ * This is used to determine the user's role in the organization.
85
+ */
86
+ grantType?: UserOrganizationGrantType;
73
87
  }
74
88
  //# sourceMappingURL=User.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../../../src/models/store/User.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,eAAO,MAAM,IAAI,cAAc,CAAA;AAE/B;;;;;;;GAOG;AACH,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,OAAO,IAAI,CAAA;IACjB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB"}
1
+ {"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../../../src/models/store/User.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAElE,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,eAAO,MAAM,IAAI,cAAc,CAAA;AAE/B,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAA;AAEvE;;;;;;;GAOG;AACH,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,OAAO,IAAI,CAAA;IACjB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,yBAAyB,CAAA;CACtC"}
@@ -1 +1 @@
1
- {"version":3,"file":"User.js","sourceRoot":"","sources":["../../../../src/models/store/User.ts"],"names":[],"mappings":"AAuBA,MAAM,CAAC,MAAM,IAAI,GAAG,WAAW,CAAA","sourcesContent":["export interface IEmail {\n /**\n * When available the email of the user.\n */\n email?: string\n /**\n * Whether the `email` was verified.\n * Not verified emails should have limited use in the system.\n */\n verified?: boolean\n}\n\nexport interface IUserPicture {\n /**\n * When available, the URL to the user's picture image.\n */\n url?: string\n /**\n * Alternative to the `url`. When set it is a data URL value of the image.\n */\n data?: string\n}\n\nexport const Kind = 'Core#User'\n\n/**\n * Represents a user in the system.\n * This can be embedded in various situations like project's revision history,\n * ACL, Authorization, etc.\n *\n * Note, the store implementation may have additional fields that support external\n * identity providers. However, this is not exposed to the user through the API.\n */\nexport interface IUser {\n kind: typeof Kind\n /**\n * The data store key of the user.\n */\n key: string\n /**\n * The display name of the user.\n */\n name: string\n /**\n * When available the email of the user.\n */\n email?: IEmail[]\n /**\n * The user picture to render.\n */\n picture?: IUserPicture\n /**\n * A general purpose tags field.\n */\n tags?: string[]\n /**\n * Optional user locale information.\n */\n locale?: string\n /**\n * Optional metadata related to the auth provider.\n */\n provider?: unknown\n /**\n * Whether the user is deleted from the system.\n */\n deleted?: boolean\n /**\n * The timestamp of when the user was deleted.\n */\n deletedTime?: number\n /**\n * The id of the user that deleted the user.\n */\n deletingUser?: string\n}\n"]}
1
+ {"version":3,"file":"User.js","sourceRoot":"","sources":["../../../../src/models/store/User.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAC,MAAM,IAAI,GAAG,WAAW,CAAA","sourcesContent":["import type { UserOrganizationGrantType } from './Organization.js'\n\nexport interface IEmail {\n /**\n * When available the email of the user.\n */\n email?: string\n /**\n * Whether the `email` was verified.\n * Not verified emails should have limited use in the system.\n */\n verified?: boolean\n}\n\nexport interface IUserPicture {\n /**\n * When available, the URL to the user's picture image.\n */\n url?: string\n /**\n * Alternative to the `url`. When set it is a data URL value of the image.\n */\n data?: string\n}\n\nexport const Kind = 'Core#User'\n\nexport type UserStatus = 'active' | 'deleted' | 'suspended' | 'pending'\n\n/**\n * Represents a user in the system.\n * This can be embedded in various situations like project's revision history,\n * ACL, Authorization, etc.\n *\n * Note, the store implementation may have additional fields that support external\n * identity providers. However, this is not exposed to the user through the API.\n */\nexport interface IUser {\n kind: typeof Kind\n /**\n * The data store key of the user.\n */\n key: string\n /**\n * The display name of the user.\n */\n name: string\n /**\n * When available the email of the user.\n */\n email?: IEmail[]\n /**\n * The user picture to render.\n */\n picture?: IUserPicture\n /**\n * A general purpose tags field.\n */\n tags?: string[]\n /**\n * Optional user locale information.\n */\n locale?: string\n /**\n * Optional metadata related to the auth provider.\n */\n provider?: unknown\n /**\n * Whether the user is deleted from the system.\n * @deprecated Use `status` instead.\n */\n deleted?: boolean\n /**\n * The timestamp of when the user was deleted.\n */\n deletedTime?: number\n /**\n * The id of the user that deleted the user.\n */\n deletingUser?: string\n /**\n * The status of the user.\n * May not be populated in all cases.\n * @default 'active'\n */\n status?: UserStatus\n /**\n * Populated when the user object is considered in the context of an organization.\n * This is used to determine the user's role in the organization.\n */\n grantType?: UserOrganizationGrantType\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 httpHeaders = { ...headers };
12
+ const { method = 'GET', headers = {}, token = this.sdk.token } = opts;
13
+ const requestHeaders = new Headers({ ...headers });
14
14
  if (token) {
15
- httpHeaders.authorization = `Bearer ${token}`;
15
+ requestHeaders.append('Authorization', `Bearer ${token}`);
16
16
  }
17
17
  const init = {
18
18
  method,
19
- headers: httpHeaders,
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,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;QACpD,MAAM,WAAW,GAAG,EAAE,GAAG,OAAO,EAAE,CAAA;QAClC,IAAI,KAAK,EAAE,CAAC;YACV,WAAW,CAAC,aAAa,GAAG,UAAU,KAAK,EAAE,CAAA;QAC/C,CAAC;QACD,MAAM,IAAI,GAAgB;YACxB,MAAM;YACN,OAAO,EAAE,WAAW;YACpB,QAAQ,EAAE,QAAQ;YAClB,WAAW,EAAE,SAAS;YACtB,IAAI,EAAE,MAAM;SACb,CAAA;QACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;QACvC,IAAI,IAAwB,CAAA;QAC5B,IAAI,CAAC;YACH,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAC9B,CAAC;QAAC,MAAM,CAAC;YACP,MAAM;QACR,CAAC;QAED,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;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AAE,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 } = opts\n const httpHeaders = { ...headers }\n if (token) {\n httpHeaders.authorization = `Bearer ${token}`\n }\n const init: RequestInit = {\n method,\n headers: httpHeaders,\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 } = 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
+ {"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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;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"]}