@api-client/core 0.13.5 → 0.14.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 (164) hide show
  1. package/build/src/amf/AmfShapeGenerator.js +1 -1
  2. package/build/src/amf/AmfShapeGenerator.js.map +1 -1
  3. package/build/src/amf/DataValueGenerator.js +1 -1
  4. package/build/src/amf/DataValueGenerator.js.map +1 -1
  5. package/build/src/amf/models/AmfDataNode.js +1 -1
  6. package/build/src/amf/models/AmfDataNode.js.map +1 -1
  7. package/build/src/browser.d.ts +1 -1
  8. package/build/src/browser.d.ts.map +1 -1
  9. package/build/src/browser.js.map +1 -1
  10. package/build/src/index.d.ts +2 -1
  11. package/build/src/index.d.ts.map +1 -1
  12. package/build/src/index.js +1 -0
  13. package/build/src/index.js.map +1 -1
  14. package/build/src/modeling/DataDomain.js +1 -1
  15. package/build/src/modeling/DataDomain.js.map +1 -1
  16. package/build/src/modeling/DomainAssociation.js +1 -1
  17. package/build/src/modeling/DomainAssociation.js.map +1 -1
  18. package/build/src/modeling/DomainEntity.js +1 -1
  19. package/build/src/modeling/DomainEntity.js.map +1 -1
  20. package/build/src/modeling/DomainFile.d.ts +2 -3
  21. package/build/src/modeling/DomainFile.d.ts.map +1 -1
  22. package/build/src/modeling/DomainFile.js +5 -9
  23. package/build/src/modeling/DomainFile.js.map +1 -1
  24. package/build/src/modeling/DomainModel.js +1 -1
  25. package/build/src/modeling/DomainModel.js.map +1 -1
  26. package/build/src/modeling/DomainNamespace.js +1 -1
  27. package/build/src/modeling/DomainNamespace.js.map +1 -1
  28. package/build/src/modeling/DomainProperty.js +1 -1
  29. package/build/src/modeling/DomainProperty.js.map +1 -1
  30. package/build/src/modeling/amf/ShapeGenerator.js +1 -1
  31. package/build/src/modeling/amf/ShapeGenerator.js.map +1 -1
  32. package/build/src/modeling/legacy/DataAssociation.js +1 -1
  33. package/build/src/modeling/legacy/DataAssociation.js.map +1 -1
  34. package/build/src/modeling/legacy/DataEntity.js +1 -1
  35. package/build/src/modeling/legacy/DataEntity.js.map +1 -1
  36. package/build/src/modeling/legacy/DataEntityBuilder.js +1 -1
  37. package/build/src/modeling/legacy/DataEntityBuilder.js.map +1 -1
  38. package/build/src/modeling/legacy/DataModel.js +1 -1
  39. package/build/src/modeling/legacy/DataModel.js.map +1 -1
  40. package/build/src/modeling/legacy/DataNamespace.js +1 -1
  41. package/build/src/modeling/legacy/DataNamespace.js.map +1 -1
  42. package/build/src/modeling/legacy/DataProperty.js +1 -1
  43. package/build/src/modeling/legacy/DataProperty.js.map +1 -1
  44. package/build/src/models/AuthorizationData.js +1 -1
  45. package/build/src/models/AuthorizationData.js.map +1 -1
  46. package/build/src/models/CertificateFile.d.ts +2 -3
  47. package/build/src/models/CertificateFile.d.ts.map +1 -1
  48. package/build/src/models/CertificateFile.js +5 -9
  49. package/build/src/models/CertificateFile.js.map +1 -1
  50. package/build/src/models/ClientCertificate.js +1 -1
  51. package/build/src/models/ClientCertificate.js.map +1 -1
  52. package/build/src/models/Environment.js +1 -1
  53. package/build/src/models/Environment.js.map +1 -1
  54. package/build/src/models/Folder.d.ts +1 -2
  55. package/build/src/models/Folder.d.ts.map +1 -1
  56. package/build/src/models/Folder.js +3 -5
  57. package/build/src/models/Folder.js.map +1 -1
  58. package/build/src/models/HostRule.js +1 -1
  59. package/build/src/models/HostRule.js.map +1 -1
  60. package/build/src/models/HttpProject.js +1 -1
  61. package/build/src/models/HttpProject.js.map +1 -1
  62. package/build/src/models/Project.d.ts +2 -3
  63. package/build/src/models/Project.d.ts.map +1 -1
  64. package/build/src/models/Project.js +5 -9
  65. package/build/src/models/Project.js.map +1 -1
  66. package/build/src/models/ProjectFolder.js +1 -1
  67. package/build/src/models/ProjectFolder.js.map +1 -1
  68. package/build/src/models/ProjectRequest.js +1 -1
  69. package/build/src/models/ProjectRequest.js.map +1 -1
  70. package/build/src/models/ProjectSchema.js +1 -1
  71. package/build/src/models/ProjectSchema.js.map +1 -1
  72. package/build/src/models/store/DataFile.d.ts +2 -4
  73. package/build/src/models/store/DataFile.d.ts.map +1 -1
  74. package/build/src/models/store/DataFile.js +5 -10
  75. package/build/src/models/store/DataFile.js.map +1 -1
  76. package/build/src/models/store/File.d.ts +1 -21
  77. package/build/src/models/store/File.d.ts.map +1 -1
  78. package/build/src/models/store/File.js +4 -24
  79. package/build/src/models/store/File.js.map +1 -1
  80. package/build/src/models/store/Invitation.js +1 -1
  81. package/build/src/models/store/Invitation.js.map +1 -1
  82. package/build/src/models/store/Organization.js +1 -1
  83. package/build/src/models/store/Organization.js.map +1 -1
  84. package/build/src/models/store/Permission.d.ts +34 -0
  85. package/build/src/models/store/Permission.d.ts.map +1 -1
  86. package/build/src/models/store/Permission.js +28 -2
  87. package/build/src/models/store/Permission.js.map +1 -1
  88. package/build/src/models/store/UserIdentity.js +1 -1
  89. package/build/src/models/store/UserIdentity.js.map +1 -1
  90. package/build/src/models/transformers/ArcDexieTransformer.js +1 -1
  91. package/build/src/models/transformers/ArcDexieTransformer.js.map +1 -1
  92. package/build/src/models/transformers/ArcLegacyTransformer.js +1 -1
  93. package/build/src/models/transformers/ArcLegacyTransformer.js.map +1 -1
  94. package/build/src/models/transformers/ArcPouchTransformer.js +1 -1
  95. package/build/src/models/transformers/ArcPouchTransformer.js.map +1 -1
  96. package/build/src/models/transformers/PostmanV21Transformer.js +1 -1
  97. package/build/src/models/transformers/PostmanV21Transformer.js.map +1 -1
  98. package/build/src/models/transformers/PostmanV2Transformer.js +1 -1
  99. package/build/src/models/transformers/PostmanV2Transformer.js.map +1 -1
  100. package/build/src/nanoid.d.ts +10 -0
  101. package/build/src/nanoid.d.ts.map +1 -0
  102. package/build/src/nanoid.js +11 -0
  103. package/build/src/nanoid.js.map +1 -0
  104. package/build/src/patch/PatchClient.js +1 -1
  105. package/build/src/patch/PatchClient.js.map +1 -1
  106. package/build/src/sdk/FilesSdk.js +2 -2
  107. package/build/src/sdk/FilesSdk.js.map +1 -1
  108. package/build/tsconfig.tsbuildinfo +1 -1
  109. package/data/models/example-generator-api.json +15 -15
  110. package/eslint.config.js +1 -0
  111. package/package.json +6 -5
  112. package/src/amf/AmfShapeGenerator.ts +1 -1
  113. package/src/amf/DataValueGenerator.ts +1 -1
  114. package/src/amf/models/AmfDataNode.ts +1 -1
  115. package/src/modeling/DataDomain.ts +1 -1
  116. package/src/modeling/DomainAssociation.ts +1 -1
  117. package/src/modeling/DomainEntity.ts +1 -1
  118. package/src/modeling/DomainFile.ts +5 -9
  119. package/src/modeling/DomainModel.ts +1 -1
  120. package/src/modeling/DomainNamespace.ts +1 -1
  121. package/src/modeling/DomainProperty.ts +1 -1
  122. package/src/modeling/amf/ShapeGenerator.ts +1 -1
  123. package/src/modeling/legacy/DataAssociation.ts +1 -1
  124. package/src/modeling/legacy/DataEntity.ts +1 -1
  125. package/src/modeling/legacy/DataEntityBuilder.ts +1 -1
  126. package/src/modeling/legacy/DataModel.ts +1 -1
  127. package/src/modeling/legacy/DataNamespace.ts +1 -1
  128. package/src/modeling/legacy/DataProperty.ts +1 -1
  129. package/src/models/AuthorizationData.ts +1 -1
  130. package/src/models/CertificateFile.ts +5 -13
  131. package/src/models/ClientCertificate.ts +1 -1
  132. package/src/models/Environment.ts +1 -1
  133. package/src/models/Folder.ts +3 -5
  134. package/src/models/HostRule.ts +1 -1
  135. package/src/models/HttpProject.ts +1 -1
  136. package/src/models/Project.ts +5 -9
  137. package/src/models/ProjectFolder.ts +1 -1
  138. package/src/models/ProjectRequest.ts +1 -1
  139. package/src/models/ProjectSchema.ts +1 -1
  140. package/src/models/store/DataFile.ts +5 -10
  141. package/src/models/store/File.ts +5 -36
  142. package/src/models/store/Invitation.ts +1 -1
  143. package/src/models/store/Organization.ts +1 -1
  144. package/src/models/store/Permission.ts +59 -2
  145. package/src/models/store/UserIdentity.ts +1 -1
  146. package/src/models/transformers/ArcDexieTransformer.ts +1 -1
  147. package/src/models/transformers/ArcLegacyTransformer.ts +1 -1
  148. package/src/models/transformers/ArcPouchTransformer.ts +1 -1
  149. package/src/models/transformers/PostmanV21Transformer.ts +1 -1
  150. package/src/models/transformers/PostmanV2Transformer.ts +1 -1
  151. package/src/nanoid.ts +10 -0
  152. package/src/patch/PatchClient.ts +1 -1
  153. package/src/sdk/FilesSdk.ts +2 -2
  154. package/tests/unit/modeling/domain_file.spec.ts +8 -27
  155. package/tests/unit/models/Certificate/from_name.spec.ts +3 -15
  156. package/tests/unit/models/File/constructor.spec.ts +0 -1
  157. package/tests/unit/models/File/new.spec.ts +2 -13
  158. package/tests/unit/models/File/shortcutTo.spec.ts +1 -2
  159. package/tests/unit/models/File/toJSON.spec.ts +2 -13
  160. package/tests/unit/models/File/updateByMeMeta.spec.ts +4 -6
  161. package/tests/unit/models/Folder/create.spec.ts +6 -23
  162. package/tests/unit/models/Permission/all.spec.ts +88 -0
  163. package/tests/unit/models/Project/create.spec.ts +10 -32
  164. package/tests/unit/runtime/proxy/HttpProjectProxy.spec.ts +1 -1
@@ -1,4 +1,4 @@
1
- import { nanoid } from 'nanoid'
1
+ import { nanoid } from '../../nanoid.js'
2
2
  import { IPermission, Permission, PermissionRole } from './Permission.js'
3
3
  import { IModification } from './Modification.js'
4
4
  import { IDeletion } from './Deletion.js'
@@ -51,19 +51,10 @@ export interface IStoredFile {
51
51
  * The identifier of the entity
52
52
  */
53
53
  key: string
54
- /**
55
- * The parent organization of the file.
56
- */
57
- organization: string
58
54
  /**
59
55
  * The file's meta info.
60
56
  */
61
57
  info: IThing
62
- /**
63
- * The owner of this object. The id of the User object.
64
- * Once the File is persistent by the API this is always populated.
65
- */
66
- owner?: string
67
58
  /**
68
59
  * The color of the icon to render for this file in the file explorer.
69
60
  * This should be a hex format, e.g.: #c00 for red.
@@ -144,7 +135,6 @@ export interface IFile extends IStoredFile {
144
135
  const parentsSymbol = Symbol('parents')
145
136
  const deletedSymbol = Symbol('deleted')
146
137
  const deletedInfoSymbol = Symbol('deletedInfo')
147
- const ownerSymbol = Symbol('owner')
148
138
  const lastModifiedSymbol = Symbol('lastModified')
149
139
  const capabilitiesSymbol = Symbol('capabilities')
150
140
  const permissionsSymbol = Symbol('permissions')
@@ -160,24 +150,10 @@ export class StoredFile {
160
150
  * The identifier of the entity
161
151
  */
162
152
  key = ''
163
- /**
164
- * The parent organization of the file.
165
- */
166
- organization = ''
167
153
  /**
168
154
  * The name of the environment.
169
155
  */
170
- info: Thing = Thing.fromName('');
171
-
172
- [ownerSymbol]?: string
173
-
174
- /**
175
- * The owner of this file. This is the id of the User object.
176
- * Set to `default` when there are no users in the system (no authentication).
177
- */
178
- get owner(): string | undefined {
179
- return this[ownerSymbol]
180
- }
156
+ info: Thing = Thing.fromName('')
181
157
 
182
158
  /**
183
159
  * The color of the icon to render for this file in the file explorer.
@@ -206,11 +182,9 @@ export class StoredFile {
206
182
  }
207
183
 
208
184
  new(init: IStoredFile): this {
209
- const { key = nanoid(), info, kind, owner, iconColor, organization, shortcutTarget } = init
185
+ const { key = nanoid(), info, kind, iconColor, shortcutTarget } = init
210
186
  this.key = key
211
- this.organization = organization
212
187
  this.kind = kind
213
- this[ownerSymbol] = owner
214
188
  if (info) {
215
189
  this.info = new Thing(info)
216
190
  } else {
@@ -230,13 +204,10 @@ export class StoredFile {
230
204
  }
231
205
 
232
206
  toJSON(): IStoredFile {
233
- const { owner } = this
234
207
  const result: IStoredFile = {
235
208
  key: this.key,
236
- organization: this.organization,
237
209
  kind: this.kind,
238
210
  info: this.info.toJSON(),
239
- owner,
240
211
  }
241
212
  if (this.iconColor) {
242
213
  result.iconColor = this.iconColor
@@ -484,19 +455,17 @@ export class File extends StoredFile {
484
455
  * @param name The name to set.
485
456
  * @param owner The user id that is the owner of the file.
486
457
  */
487
- static fromName(name: string, organization: string, owner?: string, kind = ''): File {
458
+ static fromName(name: string, kind = ''): File {
488
459
  const key = nanoid()
489
460
  const definition = new File()
490
461
  definition.new({
491
462
  key,
492
463
  kind,
493
- organization,
494
464
  info: Thing.fromName(name).toJSON(),
495
- owner,
496
465
  parents: [],
497
466
  permissionIds: [],
498
467
  permissions: [],
499
- lastModified: { user: owner || '', time: 0, byMe: false },
468
+ lastModified: { user: '', time: 0, byMe: false },
500
469
  })
501
470
  return definition
502
471
  }
@@ -1,4 +1,4 @@
1
- import { nanoid } from 'nanoid'
1
+ import { nanoid } from '../../nanoid.js'
2
2
  import { InvitationKind } from '../kinds.js'
3
3
  import type { IDeletion } from './Deletion.js'
4
4
  import type { UserOrganizationGrantType } from './Organization.js'
@@ -1,4 +1,4 @@
1
- import { nanoid } from 'nanoid'
1
+ import { nanoid } from '../../nanoid.js'
2
2
  import type { IDeletion } from './Deletion.js'
3
3
  import { OrganizationKind } from '../kinds.js'
4
4
 
@@ -1,4 +1,4 @@
1
- import { nanoid } from 'nanoid'
1
+ import { nanoid } from '../../nanoid.js'
2
2
 
3
3
  export const Kind = 'Core#Permission'
4
4
 
@@ -11,6 +11,12 @@ export type PermissionType = 'user' | 'group' | 'organization'
11
11
  */
12
12
  export type PermissionRole = 'owner' | 'reader' | 'commenter' | 'writer'
13
13
  const orderedRoles: PermissionRole[] = ['reader', 'commenter', 'writer', 'owner']
14
+ /**
15
+ * A predefined set of rules that can be used to determine the source of the permission.
16
+ * - `direct_user_grant`: The permission is granted directly to the user.
17
+ * - `creator_default_owner`: The permission is granted to the creator of the item as the default owner.
18
+ */
19
+ export type PermissionSourceRule = 'direct_user_grant' | 'creator_default_owner' | 'parent_owner_editor_rule'
14
20
 
15
21
  interface IBasePermission {
16
22
  /**
@@ -54,6 +60,20 @@ interface IBasePermission {
54
60
  * The store id of the user that added this permission.
55
61
  */
56
62
  addingUser: string
63
+ /**
64
+ * The depth of the permission in the hierarchy.
65
+ * When `0` it means that the permissions do not use inheritance.
66
+ * When `1` it means the permission is set on the item itself.
67
+ * When `2` it means the permission is set on the parent item.
68
+ * When `3` it means the permission is set on the grandparent item, and so on.
69
+ * This is used to determine the depth of the permission in the hierarchy.
70
+ */
71
+ depth: number
72
+ /**
73
+ * The source rule of the permission.
74
+ * This is used to determine how the permission was granted.
75
+ */
76
+ sourceRule: PermissionSourceRule
57
77
  }
58
78
 
59
79
  /**
@@ -118,6 +138,20 @@ export class Permission {
118
138
  * The store id of the entity that is being granted the permission.
119
139
  */
120
140
  itemId = ''
141
+ /**
142
+ * The depth of the permission in the hierarchy.
143
+ * When `0` it means that the permissions do not use inheritance.
144
+ * When `1` it means the permission is set on the item itself.
145
+ * When `2` it means the permission is set on the parent item.
146
+ * When `3` it means the permission is set on the grandparent item, and so on.
147
+ * This is used to determine the depth of the permission in the hierarchy.
148
+ */
149
+ depth = 0
150
+ /**
151
+ * The source rule of the permission.
152
+ * This is used to determine how the permission was granted.
153
+ */
154
+ sourceRule: PermissionSourceRule = 'direct_user_grant'
121
155
 
122
156
  /**
123
157
  * Creates a Permission object for a user.
@@ -136,6 +170,8 @@ export class Permission {
136
170
  role,
137
171
  type: 'user',
138
172
  addingUser,
173
+ depth: 0,
174
+ sourceRule: 'direct_user_grant',
139
175
  }
140
176
  return new Permission(init)
141
177
  }
@@ -157,6 +193,8 @@ export class Permission {
157
193
  role,
158
194
  type: 'group',
159
195
  addingUser,
196
+ depth: 0,
197
+ sourceRule: 'direct_user_grant',
160
198
  }
161
199
  return new Permission(init)
162
200
  }
@@ -182,6 +220,8 @@ export class Permission {
182
220
  role,
183
221
  type: 'organization',
184
222
  addingUser,
223
+ depth: 0,
224
+ sourceRule: 'direct_user_grant',
185
225
  }
186
226
  return new Permission(init)
187
227
  }
@@ -212,6 +252,8 @@ export class Permission {
212
252
  role: 'reader',
213
253
  type: 'user',
214
254
  addingUser: '',
255
+ depth: 0,
256
+ sourceRule: 'direct_user_grant',
215
257
  }
216
258
  }
217
259
  this.new(init)
@@ -221,7 +263,18 @@ export class Permission {
221
263
  if (!Permission.isPermission(init)) {
222
264
  throw new Error(`Not a permission.`)
223
265
  }
224
- const { key = nanoid(), granteeId, role, type, displayName, expirationTime, addingUser, itemId } = init
266
+ const {
267
+ key = nanoid(),
268
+ granteeId,
269
+ role,
270
+ type,
271
+ displayName,
272
+ expirationTime,
273
+ addingUser,
274
+ itemId,
275
+ depth,
276
+ sourceRule,
277
+ } = init
225
278
  this.kind = Kind
226
279
  this.key = key
227
280
  this.granteeId = granteeId
@@ -229,6 +282,8 @@ export class Permission {
229
282
  this.role = role
230
283
  this.type = type
231
284
  this.addingUser = addingUser
285
+ this.depth = depth || 0
286
+ this.sourceRule = sourceRule || 'direct_user_grant'
232
287
  if (displayName) {
233
288
  this.displayName = displayName
234
289
  } else {
@@ -296,6 +351,8 @@ export class Permission {
296
351
  addingUser: this.addingUser,
297
352
  granteeId: this.granteeId,
298
353
  itemId: this.itemId,
354
+ depth: this.depth,
355
+ sourceRule: this.sourceRule,
299
356
  }
300
357
  if (this.displayName) {
301
358
  result.displayName = this.displayName
@@ -1,4 +1,4 @@
1
- import { nanoid } from 'nanoid'
1
+ import { nanoid } from '../../nanoid.js'
2
2
 
3
3
  export const Kind = 'Core#UserIdentity'
4
4
 
@@ -1,4 +1,4 @@
1
- import { nanoid } from 'nanoid'
1
+ import { nanoid } from '../../nanoid.js'
2
2
  import { BaseTransformer, dataValue } from './BaseTransformer.js'
3
3
  import { Creator, Browser, Page, Entry, Header } from './har.js'
4
4
  import {
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { nanoid } from 'nanoid'
2
+ import { nanoid } from '../../nanoid.js'
3
3
  import { BaseTransformer, dataValue } from './BaseTransformer.js'
4
4
  import { ArcExportObject, ExportArcProjects, ExportArcSavedRequest } from '../legacy/DataExport.js'
5
5
 
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
 
3
- import { nanoid } from 'nanoid'
3
+ import { nanoid } from '../../nanoid.js'
4
4
  import { BaseTransformer, dataValue } from './BaseTransformer.js'
5
5
  import {
6
6
  ArcExportObject,
@@ -4,7 +4,7 @@ import { HttpProject, IHttpProject, Kind as ProjectKind } from '../HttpProject.j
4
4
  import { ProjectFolder } from '../ProjectFolder.js'
5
5
  import { ProjectRequest } from '../ProjectRequest.js'
6
6
  import { IMultipartBody } from '../../lib/transformers/PayloadSerializer.js'
7
- import { nanoid } from 'nanoid'
7
+ import { nanoid } from '../../nanoid.js'
8
8
  import { Environment } from '../Environment.js'
9
9
  import { Thing } from '../Thing.js'
10
10
 
@@ -4,7 +4,7 @@ import { HttpProject, IHttpProject, Kind as HttpProjectKind } from '../HttpProje
4
4
  import { ProjectFolder } from '../ProjectFolder.js'
5
5
  import { ProjectRequest } from '../ProjectRequest.js'
6
6
  import { IMultipartBody } from '../../lib/transformers/PayloadSerializer.js'
7
- import { nanoid } from 'nanoid'
7
+ import { nanoid } from '../../nanoid.js'
8
8
  import { Environment } from '../Environment.js'
9
9
  import { Thing } from '../Thing.js'
10
10
 
package/src/nanoid.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { customAlphabet } from 'nanoid'
2
+ /**
3
+ * The data store uses the LTREE for storing hierarchical data.
4
+ * The PG extension for LTREE requires the keys to be
5
+ * alphanumeric and underscore characters only.
6
+ * This is a custom nanoid generator that generates
7
+ * 21 character long IDs using the allowed characters. The same the API is using.
8
+ */
9
+ const nanoid = customAlphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_', 21)
10
+ export { nanoid }
@@ -1,6 +1,6 @@
1
1
  import type { Operation } from '@api-client/json/patch/types.js'
2
2
  import { JsonDocument } from '@api-client/json/patch/json_document.js'
3
- import { nanoid } from 'nanoid'
3
+ import { nanoid } from '../nanoid.js'
4
4
  import type { MediaPatchInfo, PatchInfo } from './types.js'
5
5
 
6
6
  /**
@@ -12,7 +12,7 @@ import type { FileBreadcrumb, IFile } from '../models/store/File.js'
12
12
  import { FolderKind, CertificateFileKind, ProjectKind, DomainFileKind } from '../models/kinds.js'
13
13
  import type { ContextListResult, IBulkOperationResult, ContextListOptions } from '../events/BaseEvents.js'
14
14
  import type { IAccessAddOperation, IAccessRemoveOperation, PermissionRole } from '../models/store/Permission.js'
15
- import { nanoid } from 'nanoid'
15
+ import { nanoid } from '../nanoid.js'
16
16
  import { Folder, type IFolder } from '../models/Folder.js'
17
17
  import type { AccessPatchInfo, MediaPatchInfo, MediaPatchRevision, PatchInfo } from '../patch/types.js'
18
18
  import { Exception } from '../exceptions/exception.js'
@@ -200,7 +200,7 @@ export class FilesSdk extends SdkBase {
200
200
  opts: IMetaCreateOptions = {},
201
201
  request: SdkOptions = {}
202
202
  ): Promise<IFolder> {
203
- const file = Folder.fromName(name, organization)
203
+ const file = Folder.fromName(name)
204
204
  const { token } = request
205
205
  const url = this.sdk.getUrl(RouteBuilder.files(organization))
206
206
  if (opts.parent) {
@@ -1,42 +1,28 @@
1
1
  import { test } from '@japa/runner'
2
2
  import { DomainFile, IDomainFile, ThingKind, DomainFileKind, DataDomain } from '../../../src/index.js'
3
3
 
4
- const organization = 'test-organization'
5
-
6
4
  test.group('DomainFile.fromDataDomain()', () => {
7
5
  test('sets the kind', ({ assert }) => {
8
6
  const p1 = new DataDomain({ info: { name: 'p1' } })
9
- const result = DomainFile.fromDataDomain(p1, organization)
7
+ const result = DomainFile.fromDataDomain(p1)
10
8
  assert.equal(result.kind, DomainFileKind)
11
9
  })
12
10
 
13
- test('sets the organization', ({ assert }) => {
14
- const p1 = new DataDomain({ info: { name: 'p1' } })
15
- const result = DomainFile.fromDataDomain(p1, organization)
16
- assert.equal(result.organization, organization)
17
- })
18
-
19
11
  test('sets the name', ({ assert }) => {
20
12
  const p1 = new DataDomain({ info: { name: 'p1' } })
21
- const result = DomainFile.fromDataDomain(p1, organization)
13
+ const result = DomainFile.fromDataDomain(p1)
22
14
  assert.equal(result.info.name, 'p1')
23
15
  })
24
16
 
25
17
  test('sets the key', ({ assert }) => {
26
18
  const p1 = new DataDomain({ info: { name: 'p1' } })
27
- const result = DomainFile.fromDataDomain(p1, organization)
19
+ const result = DomainFile.fromDataDomain(p1)
28
20
  assert.equal(result.key, p1.key)
29
21
  })
30
22
 
31
- test('sets the configured owner', ({ assert }) => {
32
- const p1 = new DataDomain({ info: { name: 'p1' } })
33
- const result = DomainFile.fromDataDomain(p1, organization, 'other')
34
- assert.equal(result.owner, 'other')
35
- })
36
-
37
23
  test('respects schema instead of instance', ({ assert }) => {
38
24
  const p1 = new DataDomain({ info: { name: 'p1' } })
39
- const result = DomainFile.fromDataDomain(p1.toJSON(), organization)
25
+ const result = DomainFile.fromDataDomain(p1.toJSON())
40
26
  assert.equal(result.info.name, 'p1')
41
27
  })
42
28
  })
@@ -45,7 +31,6 @@ test.group('constructor()', () => {
45
31
  test('creates a default data file', ({ assert }) => {
46
32
  const result = new DomainFile()
47
33
  assert.equal(result.kind, DomainFileKind)
48
- assert.isUndefined(result.owner)
49
34
  assert.typeOf(result.key, 'string')
50
35
  assert.typeOf(result.lastModified, 'object')
51
36
  })
@@ -53,13 +38,11 @@ test.group('constructor()', () => {
53
38
  test('creates a data file from the schema values', ({ assert }) => {
54
39
  const schema: IDomainFile = {
55
40
  kind: DomainFileKind,
56
- organization,
57
41
  info: {
58
42
  kind: ThingKind,
59
43
  name: 'hello',
60
44
  description: 'a desc',
61
45
  },
62
- owner: 'me',
63
46
  key: '123',
64
47
  parents: ['p1'],
65
48
  permissionIds: ['pr1'],
@@ -72,6 +55,8 @@ test.group('constructor()', () => {
72
55
  role: 'commenter',
73
56
  type: 'organization',
74
57
  itemId: '678',
58
+ depth: 0,
59
+ sourceRule: 'creator_default_owner',
75
60
  },
76
61
  ],
77
62
  lastModified: { byMe: false, time: 0, user: 'id', name: 'test' },
@@ -79,9 +64,7 @@ test.group('constructor()', () => {
79
64
  }
80
65
  const result = new DomainFile(schema)
81
66
  assert.equal(result.kind, DomainFileKind)
82
- assert.equal(result.organization, organization)
83
67
  assert.equal(result.info.name, 'hello')
84
- assert.equal(result.owner, 'me')
85
68
  assert.equal(result.key, '123')
86
69
  assert.deepEqual(result.parents, ['p1'])
87
70
  assert.deepEqual(result.permissionIds, ['pr1'])
@@ -93,13 +76,11 @@ test.group('constructor()', () => {
93
76
  test('creates a data file from the JSON schema string', ({ assert }) => {
94
77
  const schema: IDomainFile = {
95
78
  kind: DomainFileKind,
96
- organization,
97
79
  info: {
98
80
  kind: ThingKind,
99
81
  name: 'hello',
100
82
  description: 'a desc',
101
83
  },
102
- owner: 'me',
103
84
  key: '123',
104
85
  parents: ['p1'],
105
86
  permissionIds: ['pr1'],
@@ -112,15 +93,15 @@ test.group('constructor()', () => {
112
93
  role: 'commenter',
113
94
  type: 'organization',
114
95
  itemId: '678',
96
+ depth: 0,
97
+ sourceRule: 'creator_default_owner',
115
98
  },
116
99
  ],
117
100
  lastModified: { byMe: false, time: 0, user: 'id', name: 'test' },
118
101
  }
119
102
  const result = new DomainFile(JSON.stringify(schema))
120
103
  assert.equal(result.kind, DomainFileKind)
121
- assert.equal(result.organization, organization)
122
104
  assert.equal(result.info.name, 'hello')
123
- assert.equal(result.owner, 'me')
124
105
  assert.equal(result.key, '123')
125
106
  assert.deepEqual(result.lastModified, schema.lastModified)
126
107
  })
@@ -1,32 +1,20 @@
1
1
  import { test } from '@japa/runner'
2
2
  import { CertificateFile, CertificateFileKind } from '../../../../src/index.js'
3
3
 
4
- const organization = 'test-organization'
5
-
6
4
  test.group('CertificateFile.fromName()', () => {
7
5
  test('sets the kind', ({ assert }) => {
8
- const result = CertificateFile.fromName('name', organization)
6
+ const result = CertificateFile.fromName('name')
9
7
  assert.equal(result.kind, CertificateFileKind)
10
8
  })
11
9
 
12
- test('sets the organization', ({ assert }) => {
13
- const result = CertificateFile.fromName('name', organization)
14
- assert.equal(result.organization, organization)
15
- })
16
-
17
10
  test('sets the name', ({ assert }) => {
18
- const result = CertificateFile.fromName('name', organization)
11
+ const result = CertificateFile.fromName('name')
19
12
  assert.equal(result.info.name, 'name')
20
13
  })
21
14
 
22
15
  test('sets the key', ({ assert }) => {
23
- const result = CertificateFile.fromName('name', organization)
16
+ const result = CertificateFile.fromName('name')
24
17
  assert.typeOf(result.key, 'string')
25
18
  assert.notEqual(result.key, '')
26
19
  })
27
-
28
- test('sets the owner', ({ assert }) => {
29
- const result = CertificateFile.fromName('name', organization, 'other')
30
- assert.equal(result.owner, 'other')
31
- })
32
20
  })
@@ -5,7 +5,6 @@ test.group('File.constructor()', () => {
5
5
  test('creates a default File', ({ assert }) => {
6
6
  const result = new File()
7
7
  assert.equal(result.kind, '')
8
- assert.isUndefined(result.owner)
9
8
  assert.equal(result.key, '')
10
9
  assert.deepEqual(result.info.toJSON(), { kind: ThingKind, name: '' })
11
10
  assert.deepEqual(result.parents, [])
@@ -4,18 +4,15 @@ import { File, ThingKind, IFile } from '../../../../src/index.js'
4
4
  test.group('File.new()', (group) => {
5
5
  let file: File
6
6
  let base: IFile
7
- const organization = 'test123'
8
7
  group.each.setup(async () => {
9
8
  file = new File()
10
9
  base = {
11
10
  kind: 'test-kind',
12
- organization,
13
11
  info: {
14
12
  kind: ThingKind,
15
13
  name: 'hello',
16
14
  description: 'a desc',
17
15
  },
18
- owner: 'me',
19
16
  key: '123',
20
17
  parents: ['p1'],
21
18
  permissionIds: ['pr1'],
@@ -28,6 +25,8 @@ test.group('File.new()', (group) => {
28
25
  role: 'commenter',
29
26
  type: 'organization',
30
27
  itemId: '678',
28
+ depth: 0,
29
+ sourceRule: 'creator_default_owner',
31
30
  },
32
31
  ],
33
32
  lastModified: { byMe: false, time: 1, user: 'u1', name: 'mod-test' },
@@ -43,11 +42,6 @@ test.group('File.new()', (group) => {
43
42
  assert.equal(file.key, '123')
44
43
  })
45
44
 
46
- test('sets the organization', ({ assert }) => {
47
- file.new({ ...base })
48
- assert.equal(file.organization, organization)
49
- })
50
-
51
45
  test('sets a new key when missing', ({ assert }) => {
52
46
  const iFile = { ...base }
53
47
  Reflect.deleteProperty(iFile, 'key')
@@ -97,11 +91,6 @@ test.group('File.new()', (group) => {
97
91
  assert.deepEqual(file.permissionIds, [])
98
92
  })
99
93
 
100
- test('sets the owner', ({ assert }) => {
101
- file.new({ ...base })
102
- assert.equal(file.owner, 'me')
103
- })
104
-
105
94
  test('sets the lastModified', ({ assert }) => {
106
95
  file.new({ ...base })
107
96
  assert.deepEqual(file.lastModified, base.lastModified)
@@ -46,8 +46,7 @@ test.group('File.shortcutTo()', () => {
46
46
  })
47
47
 
48
48
  test('creates a shortcut from a name with fromName()', ({ assert }) => {
49
- const organization = 'test-org'
50
- const file = File.fromName('test-file', organization)
49
+ const file = File.fromName('test-file')
51
50
  const targetId = 'target-file-id'
52
51
  file.shortcutTo(targetId)
53
52
  assert.equal(file.shortcutTarget, targetId)
@@ -4,19 +4,16 @@ import { File, ThingKind, IFile } from '../../../../src/index.js'
4
4
  test.group('File.toJSON()', (group) => {
5
5
  let file: File
6
6
  let base: IFile
7
- const organization = 'test123'
8
7
 
9
8
  group.each.setup(() => {
10
9
  file = new File()
11
10
  base = {
12
11
  kind: 'test-kind',
13
- organization,
14
12
  info: {
15
13
  kind: ThingKind,
16
14
  name: 'hello',
17
15
  description: 'a desc',
18
16
  },
19
- owner: 'me',
20
17
  key: '123',
21
18
  parents: ['p1'],
22
19
  permissionIds: ['pr1'],
@@ -29,6 +26,8 @@ test.group('File.toJSON()', (group) => {
29
26
  role: 'commenter',
30
27
  type: 'organization',
31
28
  itemId: '678',
29
+ depth: 0,
30
+ sourceRule: 'creator_default_owner',
32
31
  },
33
32
  ],
34
33
  lastModified: { byMe: false, time: 1, user: 'u1', name: 'mod-test' },
@@ -41,21 +40,11 @@ test.group('File.toJSON()', (group) => {
41
40
  assert.equal(result.key, base.key)
42
41
  })
43
42
 
44
- test('sets the organization', ({ assert }) => {
45
- const result = file.toJSON()
46
- assert.equal(result.organization, organization)
47
- })
48
-
49
43
  test('sets the kind', ({ assert }) => {
50
44
  const result = file.toJSON()
51
45
  assert.equal(result.kind, base.kind)
52
46
  })
53
47
 
54
- test('sets the owner', ({ assert }) => {
55
- const result = file.toJSON()
56
- assert.equal(result.owner, base.owner)
57
- })
58
-
59
48
  test('sets the info', ({ assert }) => {
60
49
  const result = file.toJSON()
61
50
  assert.deepEqual(result.info, base.info)
@@ -2,10 +2,8 @@ import { test } from '@japa/runner'
2
2
  import { File, Folder } from '../../../../src/index.js'
3
3
 
4
4
  test.group('File.updateByMeMeta()', () => {
5
- const organization = 'test123'
6
-
7
5
  test('sets deletedInfo.byMe for the same user', ({ assert }) => {
8
- const schema = Folder.fromName('s1', organization).toJSON()
6
+ const schema = Folder.fromName('s1').toJSON()
9
7
  schema.deletedInfo = {
10
8
  byMe: false,
11
9
  time: 1,
@@ -17,7 +15,7 @@ test.group('File.updateByMeMeta()', () => {
17
15
  })
18
16
 
19
17
  test('sets deletedInfo.byMe for the different user', ({ assert }) => {
20
- const schema = Folder.fromName('s1', organization).toJSON()
18
+ const schema = Folder.fromName('s1').toJSON()
21
19
  schema.deletedInfo = {
22
20
  byMe: false,
23
21
  time: 1,
@@ -29,7 +27,7 @@ test.group('File.updateByMeMeta()', () => {
29
27
  })
30
28
 
31
29
  test('sets lastModified.byMe for the same user', ({ assert }) => {
32
- const schema = Folder.fromName('s1', organization).toJSON()
30
+ const schema = Folder.fromName('s1').toJSON()
33
31
  schema.lastModified = {
34
32
  byMe: false,
35
33
  time: 1,
@@ -41,7 +39,7 @@ test.group('File.updateByMeMeta()', () => {
41
39
  })
42
40
 
43
41
  test('sets lastModified.byMe for the different user', ({ assert }) => {
44
- const schema = Folder.fromName('s1', organization).toJSON()
42
+ const schema = Folder.fromName('s1').toJSON()
45
43
  schema.lastModified = {
46
44
  byMe: false,
47
45
  time: 1,