@api-client/core 0.4.2 → 0.5.0

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 (59) hide show
  1. package/build/browser.d.ts +5 -2
  2. package/build/browser.js +3 -1
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +5 -2
  5. package/build/index.js +3 -1
  6. package/build/index.js.map +1 -1
  7. package/build/src/mocking/LegacyInterfaces.d.ts +1 -1
  8. package/build/src/mocking/ProjectMock.d.ts +1 -1
  9. package/build/src/mocking/legacy/Http.js +1 -1
  10. package/build/src/mocking/legacy/Http.js.map +1 -1
  11. package/build/src/mocking/legacy/HttpResponse.d.ts +1 -1
  12. package/build/src/mocking/legacy/HttpResponse.js +1 -1
  13. package/build/src/mocking/legacy/HttpResponse.js.map +1 -1
  14. package/build/src/mocking/lib/User.d.ts +1 -6
  15. package/build/src/mocking/lib/User.js +1 -15
  16. package/build/src/mocking/lib/User.js.map +1 -1
  17. package/build/src/models/Backend.d.ts +10 -2
  18. package/build/src/models/HttpProject.js +1 -1
  19. package/build/src/models/HttpProject.js.map +1 -1
  20. package/build/src/models/Workspace.d.ts +5 -35
  21. package/build/src/models/Workspace.js +13 -35
  22. package/build/src/models/Workspace.js.map +1 -1
  23. package/build/src/models/legacy/models/base.d.ts +90 -0
  24. package/build/src/models/legacy/models/base.js +2 -0
  25. package/build/src/models/legacy/models/base.js.map +1 -0
  26. package/build/src/models/store/File.d.ts +88 -0
  27. package/build/src/models/store/File.js +82 -0
  28. package/build/src/models/store/File.js.map +1 -0
  29. package/build/src/models/store/Group.d.ts +21 -0
  30. package/build/src/models/store/Group.js +2 -0
  31. package/build/src/models/store/Group.js.map +1 -0
  32. package/build/src/models/store/Permission.d.ts +189 -0
  33. package/build/src/models/store/Permission.js +211 -0
  34. package/build/src/models/store/Permission.js.map +1 -0
  35. package/build/src/models/{User.d.ts → store/User.d.ts} +12 -59
  36. package/build/src/models/{User.js → store/User.js} +0 -0
  37. package/build/src/models/store/User.js.map +1 -0
  38. package/build/src/runtime/store/SpacesSdk.d.ts +4 -4
  39. package/build/src/runtime/store/SpacesSdk.js.map +1 -1
  40. package/build/src/runtime/store/UsersSdk.d.ts +1 -1
  41. package/json8-patch.d.ts +270 -0
  42. package/package.json +2 -2
  43. package/src/mocking/LegacyInterfaces.ts +1 -1
  44. package/src/mocking/ProjectMock.ts +1 -1
  45. package/src/mocking/legacy/Http.ts +1 -1
  46. package/src/mocking/legacy/HttpResponse.ts +1 -1
  47. package/src/mocking/lib/User.ts +1 -21
  48. package/src/models/Backend.ts +10 -2
  49. package/src/models/HttpProject.ts +1 -1
  50. package/src/models/Workspace.ts +16 -54
  51. package/src/models/legacy/models/{base.d.ts → base.ts} +0 -0
  52. package/src/models/store/File.ts +135 -0
  53. package/src/models/store/Group.ts +21 -0
  54. package/src/models/store/Permission.ts +318 -0
  55. package/src/models/store/User.ts +83 -0
  56. package/src/runtime/store/SpacesSdk.ts +5 -5
  57. package/src/runtime/store/UsersSdk.ts +1 -1
  58. package/build/src/models/User.js.map +0 -1
  59. package/src/models/User.ts +0 -138
@@ -6,7 +6,7 @@ import { History } from './lib/History.js';
6
6
 
7
7
  export { IRequestLogInit } from './lib/Request.js';
8
8
  export { IResponseInit } from './lib/Response.js';
9
- export { ISpaceUserInit, IUserInit } from './lib/User.js';
9
+ export { IUserInit } from './lib/User.js';
10
10
  export { IHttpHistoryInit, IHttpHistoryListInit } from './lib/History.js';
11
11
 
12
12
  export class ProjectMock extends DataMock {
@@ -1,5 +1,5 @@
1
1
  import { Http as Base, Types, Lorem, Time, HttpRequestInit } from '@pawel-up/data-mock';
2
- import { randomValue } from '@pawel-up/data-mock/src/lib/Http.js';
2
+ import { randomValue } from '@pawel-up/data-mock/build/src/lib/Http.js';
3
3
  import { ArcDataMockInit } from '../LegacyInterfaces.js';
4
4
  import { HttpResponse } from './HttpResponse.js';
5
5
  import { ARCHistoryRequest, ARCSavedRequest, TransportRequest } from '../../models/legacy/request/ArcRequest.js';
@@ -1,4 +1,4 @@
1
- import { HttpResponse as Base, headersValue, payloadValue, typesValue, loremValue } from '@pawel-up/data-mock/src/lib/http/HttpResponse.js';
1
+ import { HttpResponse as Base, headersValue, payloadValue, typesValue, loremValue } from '@pawel-up/data-mock/build/src/lib/http/HttpResponse.js';
2
2
  import { Har, DataMockLocale } from '@pawel-up/data-mock';
3
3
  import { ArcDataMockInit, HttpResponseArcInit, HttpResponseRedirectInit } from '../LegacyInterfaces.js';
4
4
  import { ResponseRedirect, Response, ErrorResponse } from '../../models/legacy/request/ArcResponse.js';
@@ -1,7 +1,6 @@
1
1
  import { Internet, Types, DataMockInit, Person, Random } from '@pawel-up/data-mock';
2
2
  // import { randomValue } from '@pawel-up/data-mock/src/lib/Http.js';
3
- import { IUser, ISpaceUser, AccessControlLevel, Kind as UserKind } from '../../models/User.js';
4
-
3
+ import { IUser, Kind as UserKind } from '../../models/store/User.js';
5
4
 
6
5
  export interface IUserInit {
7
6
  noEmail?: boolean;
@@ -9,13 +8,6 @@ export interface IUserInit {
9
8
  noProvider?: boolean;
10
9
  }
11
10
 
12
- export interface ISpaceUserInit extends IUserInit {
13
- level?: AccessControlLevel;
14
- levelPool?: AccessControlLevel[];
15
- }
16
-
17
- const accessPool: AccessControlLevel[] = ['read', 'comment', 'write', 'admin', 'owner'];
18
-
19
11
  export class User {
20
12
  person: Person;
21
13
  types: Types;
@@ -53,16 +45,4 @@ export class User {
53
45
  }
54
46
  return result;
55
47
  }
56
-
57
- spaceUser(init: ISpaceUserInit = {}): ISpaceUser {
58
- const user = this.user(init) as ISpaceUser;
59
- if (init.level) {
60
- user.level = init.level;
61
- } else if (Array.isArray(init.levelPool)) {
62
- user.level = this.random.pickOne(init.levelPool);
63
- } else {
64
- user.level = this.random.pickOne(accessPool);
65
- }
66
- return user;
67
- }
68
48
  }
@@ -72,7 +72,7 @@ export interface IBackendEvent extends IBackendMessage {
72
72
  id?: string;
73
73
  }
74
74
 
75
- export interface IListResponse {
75
+ export interface IListResponse<T = unknown> {
76
76
  /**
77
77
  * The cursor to use with the next query.
78
78
  * Not set when no more results.
@@ -81,7 +81,7 @@ export interface IListResponse {
81
81
  /**
82
82
  * The list of objects returned from the store.
83
83
  */
84
- data: unknown[];
84
+ data: T[];
85
85
  }
86
86
 
87
87
  export interface IListOptions {
@@ -105,7 +105,15 @@ export interface IListOptions {
105
105
  * Only with the `query` property. Tells the system in which fields to search for the query term.
106
106
  */
107
107
  queryField?: string[];
108
+ /**
109
+ * @deprecated Not sure what this is.
110
+ */
108
111
  type?: string;
112
+ /**
113
+ * Whether the list should contain children of a parent.
114
+ * This is a key of the parent.
115
+ */
116
+ parent?: string;
109
117
  }
110
118
 
111
119
  export interface ICursorOptions {
@@ -1358,7 +1358,7 @@ export class HttpProject extends ProjectParent {
1358
1358
  parent: folder.key,
1359
1359
  recursive,
1360
1360
  ignore,
1361
- }, indent += 1);
1361
+ }, indent + 1);
1362
1362
  for (const f of it) {
1363
1363
  yield f;
1364
1364
  }
@@ -1,4 +1,4 @@
1
- import { AccessControlLevel } from "./User.js";
1
+ import { IFile, File } from "./store/File.js";
2
2
  import { IThing, Thing, Kind as ThingKind } from './Thing.js';
3
3
  import v4 from '../lib/uuid.js';
4
4
 
@@ -9,7 +9,7 @@ export const Kind = 'Core#Space';
9
9
  * A working space is a logical container in the data store
10
10
  * created by the system users, where they can store their projects and other data.
11
11
  */
12
- export interface IWorkspace {
12
+ export interface IWorkspace extends IFile {
13
13
  kind: typeof Kind;
14
14
  /**
15
15
  * The space identifier.
@@ -19,27 +19,11 @@ export interface IWorkspace {
19
19
  * The environment's meta info.
20
20
  */
21
21
  info: IThing;
22
- /**
23
- * The list of users added to this space. May not be set when owner did not add anyone to the space.
24
- */
25
- users?: string[];
26
22
  /**
27
23
  * The owner of this space. The id of the User object.
28
24
  * Set to `default` when there are no users in the system (no authentication).
29
25
  */
30
26
  owner: string;
31
- /**
32
- * The list of project keys added to the workspace.
33
- * @deprecated This is not actually used.
34
- */
35
- projects: string[];
36
- }
37
-
38
- /**
39
- * The workspace information set to a specific client what contains user specific data.
40
- */
41
- export interface IUserWorkspace extends IWorkspace {
42
- access: AccessControlLevel;
43
27
  }
44
28
 
45
29
  export const DefaultOwner = 'default';
@@ -50,7 +34,7 @@ export const DefaultOwner = 'default';
50
34
  * A working space is a logical container in the data store
51
35
  * created by the system users, where they can store their projects and other data.
52
36
  */
53
- export class Workspace {
37
+ export class Workspace extends File {
54
38
  kind = Kind;
55
39
  /**
56
40
  * The space identifier.
@@ -60,26 +44,11 @@ export class Workspace {
60
44
  * The name of the environment.
61
45
  */
62
46
  info: Thing = new Thing({ kind: ThingKind });
63
- /**
64
- * The list of users added to this space. May not be set when owner did not add anyone to the space.
65
- */
66
- users?: string[];
67
47
  /**
68
48
  * The owner of this space. The id of the User object.
69
49
  * Set to `default` when there are no users in the system (no authentication).
70
50
  */
71
51
  owner = '';
72
- /**
73
- * The list of keys of projects added to the workspace.
74
- * @deprecated This is not actually used.
75
- */
76
- projects: string[] = [];
77
- /**
78
- * Only set when the object was created from the data received by the API Client backend.
79
- * Level access of the current user to the space.
80
- * Note, this information is never serialized with the object.
81
- */
82
- access?: AccessControlLevel;
83
52
 
84
53
  /**
85
54
  * Creates a new Space object from a name.
@@ -95,7 +64,9 @@ export class Workspace {
95
64
  kind: Kind,
96
65
  info: info.toJSON(),
97
66
  owner,
98
- projects: [],
67
+ parents: [],
68
+ permissionIds: [],
69
+ permissions: [],
99
70
  });
100
71
  return definition;
101
72
  }
@@ -103,7 +74,8 @@ export class Workspace {
103
74
  /**
104
75
  * @param input The environment definition used to restore the state.
105
76
  */
106
- constructor(input?: string | IWorkspace | IUserWorkspace) {
77
+ constructor(input?: string | IWorkspace) {
78
+ super();
107
79
  let init: IWorkspace;
108
80
  if (typeof input === 'string') {
109
81
  init = JSON.parse(input);
@@ -118,7 +90,9 @@ export class Workspace {
118
90
  name: '',
119
91
  },
120
92
  owner: DefaultOwner,
121
- projects: [],
93
+ parents: [],
94
+ permissionIds: [],
95
+ permissions: [],
122
96
  };
123
97
  }
124
98
  this.new(init);
@@ -129,29 +103,20 @@ export class Workspace {
129
103
  *
130
104
  * Note, this throws an error when the environment is not a space.
131
105
  */
132
- new(init: IWorkspace | IUserWorkspace): void {
106
+ new(init: IWorkspace): void {
133
107
  if (!Workspace.isWorkspace(init)) {
134
108
  throw new Error(`Not a space.`);
135
109
  }
136
- const { key = v4(), projects = [], info, owner = DefaultOwner, users } = init;
110
+ super.new(init);
111
+ const { key = v4(), info, owner = DefaultOwner } = init;
137
112
  this.kind = Kind;
138
113
  this.key = key;
139
- this.projects = projects;
140
114
  this.owner = owner;
141
115
  if (info) {
142
116
  this.info = new Thing(info);
143
117
  } else {
144
118
  this.info = new Thing({ kind: ThingKind, name: '' });
145
119
  }
146
- if (Array.isArray(users)) {
147
- this.users = [...users];
148
- } else {
149
- this.users = [];
150
- }
151
- const typed = init as IUserWorkspace;
152
- if (typed.access) {
153
- this.access = typed.access;
154
- }
155
120
  }
156
121
 
157
122
  /**
@@ -166,17 +131,14 @@ export class Workspace {
166
131
  }
167
132
 
168
133
  toJSON(): IWorkspace {
169
- const { projects = [], owner = DefaultOwner, users } = this;
134
+ const { owner = DefaultOwner } = this;
170
135
  const result: IWorkspace = {
171
136
  kind: Kind,
172
137
  key: this.key,
173
138
  info: this.info.toJSON(),
174
- projects,
175
139
  owner,
140
+ ...super.toJSON(),
176
141
  };
177
- if (Array.isArray(users) && users.length) {
178
- result.users = [...users];
179
- }
180
142
  return result;
181
143
  }
182
144
  }
File without changes
@@ -0,0 +1,135 @@
1
+ import { IPermission } from './Permission.js';
2
+
3
+ export interface IStoredFile {
4
+ /**
5
+ * The list of parents of the object. It is an ordered list of parents
6
+ * from the top (first element) to the lowest parent in the tree (last element).
7
+ *
8
+ * After creating the object, this property cannot be manipulated directly by the client.
9
+ * Should be treated as opaque value.
10
+ */
11
+ parents: string[];
12
+ /**
13
+ * The list of permissions to this file object.
14
+ *
15
+ * This property cannot be manipulated directly by the client. Should be treated as
16
+ * opaque value.
17
+ */
18
+ permissionIds: string[];
19
+ /**
20
+ * Whether the file object is deleted.
21
+ */
22
+ deleted?: boolean;
23
+ /**
24
+ * The timestamp of when the file was deleted.
25
+ */
26
+ deletedTime?: number;
27
+ /**
28
+ * The id of the user that has deleted the file.
29
+ */
30
+ deletingUser?: string;
31
+ }
32
+
33
+ /**
34
+ * An interface describing an object in the data store that
35
+ * describes a file or an object that can be treated as a file or a folder.
36
+ */
37
+ export interface IFile extends IStoredFile {
38
+ /**
39
+ * Populated by the server when reading the file. The list of permissions to the object.
40
+ *
41
+ * This property cannot be manipulated directly by the client. Should be treated as
42
+ * opaque value.
43
+ *
44
+ * Data store implementation note, this is not stored in the store but it is populated
45
+ * when reading the object.
46
+ */
47
+ permissions: IPermission[];
48
+ }
49
+
50
+ export class StoredFile {
51
+ /**
52
+ * The list of parents of the object. It is an ordered list of parents
53
+ * from the top (first element) to the lowest parent in the tree (last element).
54
+ *
55
+ * This property cannot be manipulated directly by the client. Should be treated as
56
+ * opaque value.
57
+ */
58
+ parents: string[] = [];
59
+ /**
60
+ * The list of permissions to this file object.
61
+ *
62
+ * This property cannot be manipulated directly by the client. Should be treated as
63
+ * opaque value.
64
+ */
65
+ permissionIds: string[] = [];
66
+ /**
67
+ * Whether the file object is deleted.
68
+ */
69
+ deleted?: boolean;
70
+ /**
71
+ * The timestamp of when the file was deleted.
72
+ */
73
+ deletedTime?: number;
74
+ /**
75
+ * The id of the user that has deleted the file.
76
+ */
77
+ deletingUser?: string;
78
+
79
+ new(init: IStoredFile): void {
80
+ const { parents=[], permissionIds=[], deleted, deletedTime, deletingUser } = init;
81
+ this.parents = parents;
82
+ this.permissionIds = permissionIds;
83
+ if (typeof deleted === 'boolean') {
84
+ this.deleted = deleted;
85
+ this.deletedTime = deletedTime;
86
+ this.deletingUser = deletingUser;
87
+ } else {
88
+ this.deleted = undefined;
89
+ this.deletedTime = undefined;
90
+ this.deletingUser = undefined;
91
+ }
92
+ }
93
+
94
+ toJSON(): IStoredFile {
95
+ const result: IStoredFile = {
96
+ parents: this.parents,
97
+ permissionIds: this.permissionIds,
98
+ };
99
+ if (typeof this.deleted === 'boolean') {
100
+ result.deleted = this.deleted;
101
+
102
+ if (this.deletedTime) {
103
+ result.deletedTime = this.deletedTime;
104
+ }
105
+ if (this.deletingUser) {
106
+ result.deletingUser = this.deletingUser;
107
+ }
108
+ }
109
+ return result;
110
+ }
111
+ }
112
+
113
+ export class File extends StoredFile {
114
+ /**
115
+ * Populated by the server when reading the file. The list of permissions to the object.
116
+ *
117
+ * This property cannot be manipulated directly by the client. Should be treated as
118
+ * opaque value.
119
+ */
120
+ permissions: IPermission[] = [];
121
+
122
+ new(init: IFile): void {
123
+ super.new(init);
124
+ const { permissions=[] } = init;
125
+ this.permissions = permissions;
126
+ }
127
+
128
+ toJSON(): IFile {
129
+ const result: IFile = {
130
+ ...super.toJSON(),
131
+ permissions: this.permissions,
132
+ };
133
+ return result;
134
+ }
135
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * An object representing a user group.
3
+ */
4
+ export interface IGroup {
5
+ /**
6
+ * The key of the group.
7
+ */
8
+ key: string;
9
+ /**
10
+ * The name of the group
11
+ */
12
+ name: string;
13
+ /**
14
+ * The id of the user that created this group.
15
+ */
16
+ owner: string;
17
+ /**
18
+ * The list of users in this group.
19
+ */
20
+ users: string[];
21
+ }