@balena/pinejs 17.1.0-build-model-based-typings-86a981c89f828217571c93fa010174529a5345f9-1 → 17.1.0-build-model-based-typings-e8917b7ea2db4233321dbfb73e6f23b569f3259d-1

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.
@@ -1,6 +1,6 @@
1
1
  - commits:
2
2
  - subject: Add dev model typings
3
- hash: 86a981c89f828217571c93fa010174529a5345f9
3
+ hash: e8917b7ea2db4233321dbfb73e6f23b569f3259d
4
4
  body: ""
5
5
  footer:
6
6
  Change-type: patch
@@ -8,7 +8,7 @@
8
8
  author: Pagan Gazzard
9
9
  nested: []
10
10
  - subject: Add migration model typings
11
- hash: 204e2991590943156caa470a3dbcd0c742ea0ebe
11
+ hash: 3919d0153d2deff7ca07f9a7fc4a0aacac5a4553
12
12
  body: ""
13
13
  footer:
14
14
  Change-type: patch
@@ -16,7 +16,7 @@
16
16
  author: Pagan Gazzard
17
17
  nested: []
18
18
  - subject: Add auth model typings
19
- hash: d2e4d473a0bd692ac1383e4a0c6e40f6231b6ac3
19
+ hash: 29d674142afa65a46d3b3fc8716c2379fe46db25
20
20
  body: ""
21
21
  footer:
22
22
  Change-type: patch
@@ -24,7 +24,7 @@
24
24
  author: Pagan Gazzard
25
25
  nested: []
26
26
  - subject: Switch API typings to an interface so it can be overridden/merged
27
- hash: 8c4a0d36131f3456944b92636ba9e25e624a916a
27
+ hash: ff5b099f617ae48e255562c5781797c38e42c2ac
28
28
  body: ""
29
29
  footer:
30
30
  Change-type: minor
@@ -32,7 +32,7 @@
32
32
  author: Pagan Gazzard
33
33
  nested: []
34
34
  - subject: Allow passing model typings when instantiating an internal pinejs client
35
- hash: 86785d4216e3e6c2e77822fad1a5e5fc6cc51d42
35
+ hash: d2a086e7bcfc2dc4ff59f85813c2bed787ebad80
36
36
  body: |
37
37
  Update @balena/abstract-sql-compiler from 9.1.4 to 9.2.0
38
38
  Update @balena/abstract-sql-to-typescript 3.1.1 to 3.1.2
@@ -228,9 +228,17 @@
228
228
  version: sbvr-types-7.1.2
229
229
  title: ""
230
230
  date: 2024-06-12T12:19:17.354Z
231
+ - subject: Avoid duplicate types when using sbvr-compiler to generate model types
232
+ hash: fd522e4ae75be1a7c7c927303d631c967d4bd9b9
233
+ body: ""
234
+ footer:
235
+ Change-type: patch
236
+ change-type: patch
237
+ author: Pagan Gazzard
238
+ nested: []
231
239
  version: 17.1.0
232
240
  title: ""
233
- date: 2024-06-14T14:22:11.550Z
241
+ date: 2024-06-14T15:34:17.634Z
234
242
  - commits:
235
243
  - subject: Switch from `Object.prototype.hasOwnProperty.call` to `Object.hasOwn`
236
244
  hash: 1343f0d463bf4271846343ee98de4d8afb9402f3
package/CHANGELOG.md CHANGED
@@ -73,6 +73,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
73
73
 
74
74
  </details>
75
75
 
76
+ * Avoid duplicate types when using sbvr-compiler to generate model types [Pagan Gazzard]
77
+
76
78
  # v17.0.1
77
79
  ## (2024-06-13)
78
80
 
@@ -49,11 +49,12 @@ const runCompile = async (inputFile, outputFile) => {
49
49
  (0, utils_1.writeSqlModel)(models.sql, outputFile);
50
50
  };
51
51
  const generateTypes = async (inputFile, outputFile) => {
52
- const { generateModels } = await import('../sbvr-api/sbvr-utils.js');
52
+ const { generateLfModel, generateAbstractSqlModel } = await import('../sbvr-api/sbvr-utils.js');
53
53
  const seModel = getSE(inputFile);
54
- const models = generateModels({ apiRoot: 'sbvr-compiler', modelText: seModel }, commander_1.program.opts().engine);
54
+ const lfModel = generateLfModel(seModel);
55
+ const abstractSql = generateAbstractSqlModel(lfModel);
55
56
  const { abstractSqlToTypescriptTypes } = await import('@balena/abstract-sql-to-typescript/generate');
56
- const types = abstractSqlToTypescriptTypes(models.abstractSql);
57
+ const types = abstractSqlToTypescriptTypes(abstractSql);
57
58
  (0, utils_1.writeAll)(types, outputFile);
58
59
  };
59
60
  commander_1.program
@@ -1 +1 @@
1
- {"version":3,"file":"sbv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AAC;IAC/B,mBAAO,CAAC,IAAI,EAAE,CAAC;AAChB,CAAC;AAED,KAAK,mBAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -51,63 +51,8 @@ export interface MigrationStatus {
51
51
  converged_time: Types['Date Time']['Write'] | null;
52
52
  };
53
53
  }
54
- export interface Migration {
55
- Read: {
56
- created_at: Types['Date Time']['Read'];
57
- modified_at: Types['Date Time']['Read'];
58
- model_name: Types['Short Text']['Read'];
59
- executed_migrations: Types['JSON']['Read'];
60
- };
61
- Write: {
62
- created_at: Types['Date Time']['Write'];
63
- modified_at: Types['Date Time']['Write'];
64
- model_name: Types['Short Text']['Write'];
65
- executed_migrations: Types['JSON']['Write'];
66
- };
67
- }
68
- export interface MigrationLock {
69
- Read: {
70
- created_at: Types['Date Time']['Read'];
71
- modified_at: Types['Date Time']['Read'];
72
- model_name: Types['Short Text']['Read'];
73
- };
74
- Write: {
75
- created_at: Types['Date Time']['Write'];
76
- modified_at: Types['Date Time']['Write'];
77
- model_name: Types['Short Text']['Write'];
78
- };
79
- }
80
- export interface MigrationStatus {
81
- Read: {
82
- created_at: Types['Date Time']['Read'];
83
- modified_at: Types['Date Time']['Read'];
84
- migration_key: Types['Short Text']['Read'];
85
- start_time: Types['Date Time']['Read'] | null;
86
- last_run_time: Types['Date Time']['Read'] | null;
87
- run_count: Types['Integer']['Read'];
88
- migrated_row_count: Types['Integer']['Read'] | null;
89
- error_count: Types['Integer']['Read'] | null;
90
- is_backing_off: Types['Boolean']['Read'];
91
- converged_time: Types['Date Time']['Read'] | null;
92
- };
93
- Write: {
94
- created_at: Types['Date Time']['Write'];
95
- modified_at: Types['Date Time']['Write'];
96
- migration_key: Types['Short Text']['Write'];
97
- start_time: Types['Date Time']['Write'] | null;
98
- last_run_time: Types['Date Time']['Write'] | null;
99
- run_count: Types['Integer']['Write'];
100
- migrated_row_count: Types['Integer']['Write'] | null;
101
- error_count: Types['Integer']['Write'] | null;
102
- is_backing_off: Types['Boolean']['Write'];
103
- converged_time: Types['Date Time']['Write'] | null;
104
- };
105
- }
106
54
  export default interface $Model {
107
55
  migration: Migration;
108
56
  migration_lock: MigrationLock;
109
57
  migration_status: MigrationStatus;
110
- migration$sbvr__compiler: Migration;
111
- migration_lock$sbvr__compiler: MigrationLock;
112
- migration_status$sbvr__compiler: MigrationStatus;
113
58
  }
@@ -17,25 +17,6 @@ export interface Model {
17
17
  model_value: Types['JSON']['Write'];
18
18
  };
19
19
  }
20
- export interface Model {
21
- Read: {
22
- created_at: Types['Date Time']['Read'];
23
- modified_at: Types['Date Time']['Read'];
24
- id: Types['Serial']['Read'];
25
- is_of__vocabulary: Types['Short Text']['Read'];
26
- model_type: Types['Short Text']['Read'];
27
- model_value: Types['JSON']['Read'];
28
- };
29
- Write: {
30
- created_at: Types['Date Time']['Write'];
31
- modified_at: Types['Date Time']['Write'];
32
- id: Types['Serial']['Write'];
33
- is_of__vocabulary: Types['Short Text']['Write'];
34
- model_type: Types['Short Text']['Write'];
35
- model_value: Types['JSON']['Write'];
36
- };
37
- }
38
20
  export default interface $Model {
39
21
  model: Model;
40
- model$sbvr__compiler: Model;
41
22
  }
@@ -108,22 +108,22 @@ export declare class PinejsClient<M extends {
108
108
  req?: permissions.PermissionReq;
109
109
  custom?: AnyObject;
110
110
  }): Promise<object>;
111
- post<TResource extends keyof M & string>(params: {
112
- resource: TResource;
113
- options: Params<M[TResource]>['options'] & {
114
- returnResource: false;
115
- };
116
- } & Params<M[TResource]>): Promise<Pick<M[TResource]['Read'], 'id'>>;
117
111
  post<TResource extends keyof M & string>(params: {
118
112
  resource: TResource;
119
113
  options?: Params<M[TResource]>['options'] & {
120
114
  returnResource?: true;
121
115
  };
122
116
  } & Params<M[TResource]>): Promise<M[TResource]['Read']>;
117
+ post<TResource extends keyof M & string>(params: {
118
+ resource: TResource;
119
+ options: Params<M[TResource]>['options'] & {
120
+ returnResource: boolean;
121
+ };
122
+ } & Params<M[TResource]>): Promise<Pick<M[TResource]['Read'], 'id'>>;
123
123
  post<T extends Resource = AnyResource>(params: {
124
124
  resource?: undefined;
125
125
  url: NonNullable<Params<T>['url']>;
126
- } & Params<T>): Promise<T>;
126
+ } & Params<T>): Promise<AnyObject>;
127
127
  }
128
128
  export interface API {
129
129
  [vocab: string]: PinejsClient;
@@ -220,227 +220,6 @@ export interface ApiKeyHasPermission {
220
220
  id: Types['Serial']['Write'];
221
221
  };
222
222
  }
223
- export interface Permission {
224
- Read: {
225
- created_at: Types['Date Time']['Read'];
226
- modified_at: Types['Date Time']['Read'];
227
- id: Types['Serial']['Read'];
228
- name: Types['Text']['Read'];
229
- is_of__role?: Array<RoleHasPermission['Read']>;
230
- is_of__user?: Array<UserHasPermission['Read']>;
231
- is_of__api_key?: Array<ApiKeyHasPermission['Read']>;
232
- user__has__permission?: Array<UserHasPermission['Read']>;
233
- user_permission?: Array<UserHasPermission['Read']>;
234
- };
235
- Write: {
236
- created_at: Types['Date Time']['Write'];
237
- modified_at: Types['Date Time']['Write'];
238
- id: Types['Serial']['Write'];
239
- name: Types['Text']['Write'];
240
- };
241
- }
242
- export interface Role {
243
- Read: {
244
- created_at: Types['Date Time']['Read'];
245
- modified_at: Types['Date Time']['Read'];
246
- id: Types['Serial']['Read'];
247
- name: Types['Text']['Read'];
248
- role__has__permission?: Array<RoleHasPermission['Read']>;
249
- user__has__role?: Array<UserHasRole['Read']>;
250
- user_role?: Array<UserHasRole['Read']>;
251
- is_of__user?: Array<UserHasRole['Read']>;
252
- is_of__api_key?: Array<ApiKeyHasRole['Read']>;
253
- };
254
- Write: {
255
- created_at: Types['Date Time']['Write'];
256
- modified_at: Types['Date Time']['Write'];
257
- id: Types['Serial']['Write'];
258
- name: Types['Text']['Write'];
259
- };
260
- }
261
- export interface RoleHasPermission {
262
- Read: {
263
- created_at: Types['Date Time']['Read'];
264
- modified_at: Types['Date Time']['Read'];
265
- role: {
266
- __id: Role['Read']['id'];
267
- } | [Role['Read']];
268
- permission: {
269
- __id: Permission['Read']['id'];
270
- } | [Permission['Read']];
271
- id: Types['Serial']['Read'];
272
- is_of__role: {
273
- __id: Role['Read']['id'];
274
- } | [Role['Read']];
275
- };
276
- Write: {
277
- created_at: Types['Date Time']['Write'];
278
- modified_at: Types['Date Time']['Write'];
279
- role: Role['Write']['id'];
280
- permission: Permission['Write']['id'];
281
- id: Types['Serial']['Write'];
282
- };
283
- }
284
- export interface Actor {
285
- Read: {
286
- created_at: Types['Date Time']['Read'];
287
- modified_at: Types['Date Time']['Read'];
288
- id: Types['Serial']['Read'];
289
- is_of__user?: Array<User['Read']>;
290
- api_key?: Array<ApiKey['Read']>;
291
- };
292
- Write: {
293
- created_at: Types['Date Time']['Write'];
294
- modified_at: Types['Date Time']['Write'];
295
- id: Types['Serial']['Write'];
296
- };
297
- }
298
- export interface User {
299
- Read: {
300
- created_at: Types['Date Time']['Read'];
301
- modified_at: Types['Date Time']['Read'];
302
- id: Types['Serial']['Read'];
303
- actor: {
304
- __id: Actor['Read']['id'];
305
- } | [Actor['Read']];
306
- username: Types['Short Text']['Read'];
307
- password: Types['Hashed']['Read'];
308
- user__has__role?: Array<UserHasRole['Read']>;
309
- user_role?: Array<UserHasRole['Read']>;
310
- user__has__permission?: Array<UserHasPermission['Read']>;
311
- user_permission?: Array<UserHasPermission['Read']>;
312
- };
313
- Write: {
314
- created_at: Types['Date Time']['Write'];
315
- modified_at: Types['Date Time']['Write'];
316
- id: Types['Serial']['Write'];
317
- actor: Actor['Write']['id'];
318
- username: Types['Short Text']['Write'];
319
- password: Types['Hashed']['Write'];
320
- };
321
- }
322
- export interface UserHasRole {
323
- Read: {
324
- created_at: Types['Date Time']['Read'];
325
- modified_at: Types['Date Time']['Read'];
326
- user: {
327
- __id: User['Read']['id'];
328
- } | [User['Read']];
329
- role: {
330
- __id: Role['Read']['id'];
331
- } | [Role['Read']];
332
- id: Types['Serial']['Read'];
333
- expiry_date: Types['Date Time']['Read'] | null;
334
- is_of__user: {
335
- __id: User['Read']['id'];
336
- } | [User['Read']];
337
- };
338
- Write: {
339
- created_at: Types['Date Time']['Write'];
340
- modified_at: Types['Date Time']['Write'];
341
- user: User['Write']['id'];
342
- role: Role['Write']['id'];
343
- id: Types['Serial']['Write'];
344
- expiry_date: Types['Date Time']['Write'] | null;
345
- };
346
- }
347
- export interface UserHasPermission {
348
- Read: {
349
- created_at: Types['Date Time']['Read'];
350
- modified_at: Types['Date Time']['Read'];
351
- user: {
352
- __id: User['Read']['id'];
353
- } | [User['Read']];
354
- permission: {
355
- __id: Permission['Read']['id'];
356
- } | [Permission['Read']];
357
- id: Types['Serial']['Read'];
358
- expiry_date: Types['Date Time']['Read'] | null;
359
- is_of__user: {
360
- __id: User['Read']['id'];
361
- } | [User['Read']];
362
- };
363
- Write: {
364
- created_at: Types['Date Time']['Write'];
365
- modified_at: Types['Date Time']['Write'];
366
- user: User['Write']['id'];
367
- permission: Permission['Write']['id'];
368
- id: Types['Serial']['Write'];
369
- expiry_date: Types['Date Time']['Write'] | null;
370
- };
371
- }
372
- export interface ApiKey {
373
- Read: {
374
- created_at: Types['Date Time']['Read'];
375
- modified_at: Types['Date Time']['Read'];
376
- id: Types['Serial']['Read'];
377
- key: Types['Short Text']['Read'];
378
- expiry_date: Types['Date Time']['Read'] | null;
379
- is_of__actor: {
380
- __id: Actor['Read']['id'];
381
- } | [Actor['Read']];
382
- name: Types['Text']['Read'] | null;
383
- description: Types['Text']['Read'] | null;
384
- api_key__has__role?: Array<ApiKeyHasRole['Read']>;
385
- api_key__has__permission?: Array<ApiKeyHasPermission['Read']>;
386
- };
387
- Write: {
388
- created_at: Types['Date Time']['Write'];
389
- modified_at: Types['Date Time']['Write'];
390
- id: Types['Serial']['Write'];
391
- key: Types['Short Text']['Write'];
392
- expiry_date: Types['Date Time']['Write'] | null;
393
- is_of__actor: Actor['Write']['id'];
394
- name: Types['Text']['Write'] | null;
395
- description: Types['Text']['Write'] | null;
396
- };
397
- }
398
- export interface ApiKeyHasRole {
399
- Read: {
400
- created_at: Types['Date Time']['Read'];
401
- modified_at: Types['Date Time']['Read'];
402
- api_key: {
403
- __id: ApiKey['Read']['id'];
404
- } | [ApiKey['Read']];
405
- role: {
406
- __id: Role['Read']['id'];
407
- } | [Role['Read']];
408
- id: Types['Serial']['Read'];
409
- is_of__api_key: {
410
- __id: ApiKey['Read']['id'];
411
- } | [ApiKey['Read']];
412
- };
413
- Write: {
414
- created_at: Types['Date Time']['Write'];
415
- modified_at: Types['Date Time']['Write'];
416
- api_key: ApiKey['Write']['id'];
417
- role: Role['Write']['id'];
418
- id: Types['Serial']['Write'];
419
- };
420
- }
421
- export interface ApiKeyHasPermission {
422
- Read: {
423
- created_at: Types['Date Time']['Read'];
424
- modified_at: Types['Date Time']['Read'];
425
- api_key: {
426
- __id: ApiKey['Read']['id'];
427
- } | [ApiKey['Read']];
428
- permission: {
429
- __id: Permission['Read']['id'];
430
- } | [Permission['Read']];
431
- id: Types['Serial']['Read'];
432
- is_of__api_key: {
433
- __id: ApiKey['Read']['id'];
434
- } | [ApiKey['Read']];
435
- };
436
- Write: {
437
- created_at: Types['Date Time']['Write'];
438
- modified_at: Types['Date Time']['Write'];
439
- api_key: ApiKey['Write']['id'];
440
- permission: Permission['Write']['id'];
441
- id: Types['Serial']['Write'];
442
- };
443
- }
444
223
  export default interface $Model {
445
224
  permission: Permission;
446
225
  role: Role;
@@ -452,16 +231,6 @@ export default interface $Model {
452
231
  api_key: ApiKey;
453
232
  api_key__has__role: ApiKeyHasRole;
454
233
  api_key__has__permission: ApiKeyHasPermission;
455
- permission$sbvr__compiler: Permission;
456
- role$sbvr__compiler: Role;
457
- role__has__permission$sbvr__compiler: RoleHasPermission;
458
- actor$sbvr__compiler: Actor;
459
- user$sbvr__compiler: User;
460
- user__has__role$sbvr__compiler: UserHasRole;
461
- user__has__permission$sbvr__compiler: UserHasPermission;
462
- api_key$sbvr__compiler: ApiKey;
463
- api_key__has__role$sbvr__compiler: ApiKeyHasRole;
464
- api_key__has__permission$sbvr__compiler: ApiKeyHasPermission;
465
234
  user_role: UserHasRole;
466
235
  user_permission: UserHasPermission;
467
236
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@balena/pinejs",
3
- "version": "17.1.0-build-model-based-typings-86a981c89f828217571c93fa010174529a5345f9-1",
3
+ "version": "17.1.0-build-model-based-typings-e8917b7ea2db4233321dbfb73e6f23b569f3259d-1",
4
4
  "main": "out/server-glue/module",
5
5
  "type": "commonjs",
6
6
  "repository": "git@github.com:balena-io/pinejs.git",
@@ -146,6 +146,6 @@
146
146
  "recursive": true
147
147
  },
148
148
  "versionist": {
149
- "publishedAt": "2024-06-14T14:22:13.242Z"
149
+ "publishedAt": "2024-06-14T15:34:19.120Z"
150
150
  }
151
151
  }
@@ -35,16 +35,16 @@ const runCompile = async (inputFile: string, outputFile?: string) => {
35
35
  };
36
36
 
37
37
  const generateTypes = async (inputFile: string, outputFile?: string) => {
38
- const { generateModels } = await import('../sbvr-api/sbvr-utils.js');
39
- const seModel = getSE(inputFile);
40
- const models = generateModels(
41
- { apiRoot: 'sbvr-compiler', modelText: seModel },
42
- program.opts().engine,
38
+ const { generateLfModel, generateAbstractSqlModel } = await import(
39
+ '../sbvr-api/sbvr-utils.js'
43
40
  );
41
+ const seModel = getSE(inputFile);
42
+ const lfModel = generateLfModel(seModel);
43
+ const abstractSql = generateAbstractSqlModel(lfModel);
44
44
  const { abstractSqlToTypescriptTypes } = await import(
45
45
  '@balena/abstract-sql-to-typescript/generate'
46
46
  );
47
- const types = abstractSqlToTypescriptTypes(models.abstractSql);
47
+ const types = abstractSqlToTypescriptTypes(abstractSql);
48
48
 
49
49
  writeAll(types, outputFile);
50
50
  };
@@ -55,66 +55,8 @@ export interface MigrationStatus {
55
55
  };
56
56
  }
57
57
 
58
- export interface Migration {
59
- Read: {
60
- created_at: Types['Date Time']['Read'];
61
- modified_at: Types['Date Time']['Read'];
62
- model_name: Types['Short Text']['Read'];
63
- executed_migrations: Types['JSON']['Read'];
64
- };
65
- Write: {
66
- created_at: Types['Date Time']['Write'];
67
- modified_at: Types['Date Time']['Write'];
68
- model_name: Types['Short Text']['Write'];
69
- executed_migrations: Types['JSON']['Write'];
70
- };
71
- }
72
-
73
- export interface MigrationLock {
74
- Read: {
75
- created_at: Types['Date Time']['Read'];
76
- modified_at: Types['Date Time']['Read'];
77
- model_name: Types['Short Text']['Read'];
78
- };
79
- Write: {
80
- created_at: Types['Date Time']['Write'];
81
- modified_at: Types['Date Time']['Write'];
82
- model_name: Types['Short Text']['Write'];
83
- };
84
- }
85
-
86
- export interface MigrationStatus {
87
- Read: {
88
- created_at: Types['Date Time']['Read'];
89
- modified_at: Types['Date Time']['Read'];
90
- migration_key: Types['Short Text']['Read'];
91
- start_time: Types['Date Time']['Read'] | null;
92
- last_run_time: Types['Date Time']['Read'] | null;
93
- run_count: Types['Integer']['Read'];
94
- migrated_row_count: Types['Integer']['Read'] | null;
95
- error_count: Types['Integer']['Read'] | null;
96
- is_backing_off: Types['Boolean']['Read'];
97
- converged_time: Types['Date Time']['Read'] | null;
98
- };
99
- Write: {
100
- created_at: Types['Date Time']['Write'];
101
- modified_at: Types['Date Time']['Write'];
102
- migration_key: Types['Short Text']['Write'];
103
- start_time: Types['Date Time']['Write'] | null;
104
- last_run_time: Types['Date Time']['Write'] | null;
105
- run_count: Types['Integer']['Write'];
106
- migrated_row_count: Types['Integer']['Write'] | null;
107
- error_count: Types['Integer']['Write'] | null;
108
- is_backing_off: Types['Boolean']['Write'];
109
- converged_time: Types['Date Time']['Write'] | null;
110
- };
111
- }
112
-
113
58
  export default interface $Model {
114
59
  migration: Migration;
115
60
  migration_lock: MigrationLock;
116
61
  migration_status: MigrationStatus;
117
- migration$sbvr__compiler: Migration;
118
- migration_lock$sbvr__compiler: MigrationLock;
119
- migration_status$sbvr__compiler: MigrationStatus;
120
62
  }
@@ -19,26 +19,6 @@ export interface Model {
19
19
  };
20
20
  }
21
21
 
22
- export interface Model {
23
- Read: {
24
- created_at: Types['Date Time']['Read'];
25
- modified_at: Types['Date Time']['Read'];
26
- id: Types['Serial']['Read'];
27
- is_of__vocabulary: Types['Short Text']['Read'];
28
- model_type: Types['Short Text']['Read'];
29
- model_value: Types['JSON']['Read'];
30
- };
31
- Write: {
32
- created_at: Types['Date Time']['Write'];
33
- modified_at: Types['Date Time']['Write'];
34
- id: Types['Serial']['Write'];
35
- is_of__vocabulary: Types['Short Text']['Write'];
36
- model_type: Types['Short Text']['Write'];
37
- model_value: Types['JSON']['Write'];
38
- };
39
- }
40
-
41
22
  export default interface $Model {
42
23
  model: Model;
43
- model$sbvr__compiler: Model;
44
24
  }
@@ -1036,15 +1036,15 @@ export class PinejsClient<
1036
1036
  public post<TResource extends keyof M & string>(
1037
1037
  params: {
1038
1038
  resource: TResource;
1039
- options: Params<M[TResource]>['options'] & { returnResource: false };
1039
+ options?: Params<M[TResource]>['options'] & { returnResource?: true };
1040
1040
  } & Params<M[TResource]>,
1041
- ): Promise<Pick<M[TResource]['Read'], 'id'>>; // TODO: This should use the primary key rather than hardcoding `id`
1041
+ ): Promise<M[TResource]['Read']>;
1042
1042
  public post<TResource extends keyof M & string>(
1043
1043
  params: {
1044
1044
  resource: TResource;
1045
- options?: Params<M[TResource]>['options'] & { returnResource?: true };
1045
+ options: Params<M[TResource]>['options'] & { returnResource: boolean };
1046
1046
  } & Params<M[TResource]>,
1047
- ): Promise<M[TResource]['Read']>;
1047
+ ): Promise<Pick<M[TResource]['Read'], 'id'>>; // TODO: This should use the primary key rather than hardcoding `id`
1048
1048
  /**
1049
1049
  * @deprecated POSTing via `url` is deprecated
1050
1050
  */
@@ -1053,7 +1053,7 @@ export class PinejsClient<
1053
1053
  resource?: undefined;
1054
1054
  url: NonNullable<Params<T>['url']>;
1055
1055
  } & Params<T>,
1056
- ): Promise<T>;
1056
+ ): Promise<AnyObject>;
1057
1057
  public post(params: Params<AnyResource>): Promise<AnyObject> {
1058
1058
  return super.post(params as Parameters<PinejsClient['post']>[0]);
1059
1059
  }
@@ -197,203 +197,6 @@ export interface ApiKeyHasPermission {
197
197
  };
198
198
  }
199
199
 
200
- export interface Permission {
201
- Read: {
202
- created_at: Types['Date Time']['Read'];
203
- modified_at: Types['Date Time']['Read'];
204
- id: Types['Serial']['Read'];
205
- name: Types['Text']['Read'];
206
- is_of__role?: Array<RoleHasPermission['Read']>;
207
- is_of__user?: Array<UserHasPermission['Read']>;
208
- is_of__api_key?: Array<ApiKeyHasPermission['Read']>;
209
- user__has__permission?: Array<UserHasPermission['Read']>;
210
- user_permission?: Array<UserHasPermission['Read']>;
211
- };
212
- Write: {
213
- created_at: Types['Date Time']['Write'];
214
- modified_at: Types['Date Time']['Write'];
215
- id: Types['Serial']['Write'];
216
- name: Types['Text']['Write'];
217
- };
218
- }
219
-
220
- export interface Role {
221
- Read: {
222
- created_at: Types['Date Time']['Read'];
223
- modified_at: Types['Date Time']['Read'];
224
- id: Types['Serial']['Read'];
225
- name: Types['Text']['Read'];
226
- role__has__permission?: Array<RoleHasPermission['Read']>;
227
- user__has__role?: Array<UserHasRole['Read']>;
228
- user_role?: Array<UserHasRole['Read']>;
229
- is_of__user?: Array<UserHasRole['Read']>;
230
- is_of__api_key?: Array<ApiKeyHasRole['Read']>;
231
- };
232
- Write: {
233
- created_at: Types['Date Time']['Write'];
234
- modified_at: Types['Date Time']['Write'];
235
- id: Types['Serial']['Write'];
236
- name: Types['Text']['Write'];
237
- };
238
- }
239
-
240
- export interface RoleHasPermission {
241
- Read: {
242
- created_at: Types['Date Time']['Read'];
243
- modified_at: Types['Date Time']['Read'];
244
- role: { __id: Role['Read']['id'] } | [Role['Read']];
245
- permission: { __id: Permission['Read']['id'] } | [Permission['Read']];
246
- id: Types['Serial']['Read'];
247
- is_of__role: { __id: Role['Read']['id'] } | [Role['Read']];
248
- };
249
- Write: {
250
- created_at: Types['Date Time']['Write'];
251
- modified_at: Types['Date Time']['Write'];
252
- role: Role['Write']['id'];
253
- permission: Permission['Write']['id'];
254
- id: Types['Serial']['Write'];
255
- };
256
- }
257
-
258
- export interface Actor {
259
- Read: {
260
- created_at: Types['Date Time']['Read'];
261
- modified_at: Types['Date Time']['Read'];
262
- id: Types['Serial']['Read'];
263
- is_of__user?: Array<User['Read']>;
264
- api_key?: Array<ApiKey['Read']>;
265
- };
266
- Write: {
267
- created_at: Types['Date Time']['Write'];
268
- modified_at: Types['Date Time']['Write'];
269
- id: Types['Serial']['Write'];
270
- };
271
- }
272
-
273
- export interface User {
274
- Read: {
275
- created_at: Types['Date Time']['Read'];
276
- modified_at: Types['Date Time']['Read'];
277
- id: Types['Serial']['Read'];
278
- actor: { __id: Actor['Read']['id'] } | [Actor['Read']];
279
- username: Types['Short Text']['Read'];
280
- password: Types['Hashed']['Read'];
281
- user__has__role?: Array<UserHasRole['Read']>;
282
- user_role?: Array<UserHasRole['Read']>;
283
- user__has__permission?: Array<UserHasPermission['Read']>;
284
- user_permission?: Array<UserHasPermission['Read']>;
285
- };
286
- Write: {
287
- created_at: Types['Date Time']['Write'];
288
- modified_at: Types['Date Time']['Write'];
289
- id: Types['Serial']['Write'];
290
- actor: Actor['Write']['id'];
291
- username: Types['Short Text']['Write'];
292
- password: Types['Hashed']['Write'];
293
- };
294
- }
295
-
296
- export interface UserHasRole {
297
- Read: {
298
- created_at: Types['Date Time']['Read'];
299
- modified_at: Types['Date Time']['Read'];
300
- user: { __id: User['Read']['id'] } | [User['Read']];
301
- role: { __id: Role['Read']['id'] } | [Role['Read']];
302
- id: Types['Serial']['Read'];
303
- expiry_date: Types['Date Time']['Read'] | null;
304
- is_of__user: { __id: User['Read']['id'] } | [User['Read']];
305
- };
306
- Write: {
307
- created_at: Types['Date Time']['Write'];
308
- modified_at: Types['Date Time']['Write'];
309
- user: User['Write']['id'];
310
- role: Role['Write']['id'];
311
- id: Types['Serial']['Write'];
312
- expiry_date: Types['Date Time']['Write'] | null;
313
- };
314
- }
315
-
316
- export interface UserHasPermission {
317
- Read: {
318
- created_at: Types['Date Time']['Read'];
319
- modified_at: Types['Date Time']['Read'];
320
- user: { __id: User['Read']['id'] } | [User['Read']];
321
- permission: { __id: Permission['Read']['id'] } | [Permission['Read']];
322
- id: Types['Serial']['Read'];
323
- expiry_date: Types['Date Time']['Read'] | null;
324
- is_of__user: { __id: User['Read']['id'] } | [User['Read']];
325
- };
326
- Write: {
327
- created_at: Types['Date Time']['Write'];
328
- modified_at: Types['Date Time']['Write'];
329
- user: User['Write']['id'];
330
- permission: Permission['Write']['id'];
331
- id: Types['Serial']['Write'];
332
- expiry_date: Types['Date Time']['Write'] | null;
333
- };
334
- }
335
-
336
- export interface ApiKey {
337
- Read: {
338
- created_at: Types['Date Time']['Read'];
339
- modified_at: Types['Date Time']['Read'];
340
- id: Types['Serial']['Read'];
341
- key: Types['Short Text']['Read'];
342
- expiry_date: Types['Date Time']['Read'] | null;
343
- is_of__actor: { __id: Actor['Read']['id'] } | [Actor['Read']];
344
- name: Types['Text']['Read'] | null;
345
- description: Types['Text']['Read'] | null;
346
- api_key__has__role?: Array<ApiKeyHasRole['Read']>;
347
- api_key__has__permission?: Array<ApiKeyHasPermission['Read']>;
348
- };
349
- Write: {
350
- created_at: Types['Date Time']['Write'];
351
- modified_at: Types['Date Time']['Write'];
352
- id: Types['Serial']['Write'];
353
- key: Types['Short Text']['Write'];
354
- expiry_date: Types['Date Time']['Write'] | null;
355
- is_of__actor: Actor['Write']['id'];
356
- name: Types['Text']['Write'] | null;
357
- description: Types['Text']['Write'] | null;
358
- };
359
- }
360
-
361
- export interface ApiKeyHasRole {
362
- Read: {
363
- created_at: Types['Date Time']['Read'];
364
- modified_at: Types['Date Time']['Read'];
365
- api_key: { __id: ApiKey['Read']['id'] } | [ApiKey['Read']];
366
- role: { __id: Role['Read']['id'] } | [Role['Read']];
367
- id: Types['Serial']['Read'];
368
- is_of__api_key: { __id: ApiKey['Read']['id'] } | [ApiKey['Read']];
369
- };
370
- Write: {
371
- created_at: Types['Date Time']['Write'];
372
- modified_at: Types['Date Time']['Write'];
373
- api_key: ApiKey['Write']['id'];
374
- role: Role['Write']['id'];
375
- id: Types['Serial']['Write'];
376
- };
377
- }
378
-
379
- export interface ApiKeyHasPermission {
380
- Read: {
381
- created_at: Types['Date Time']['Read'];
382
- modified_at: Types['Date Time']['Read'];
383
- api_key: { __id: ApiKey['Read']['id'] } | [ApiKey['Read']];
384
- permission: { __id: Permission['Read']['id'] } | [Permission['Read']];
385
- id: Types['Serial']['Read'];
386
- is_of__api_key: { __id: ApiKey['Read']['id'] } | [ApiKey['Read']];
387
- };
388
- Write: {
389
- created_at: Types['Date Time']['Write'];
390
- modified_at: Types['Date Time']['Write'];
391
- api_key: ApiKey['Write']['id'];
392
- permission: Permission['Write']['id'];
393
- id: Types['Serial']['Write'];
394
- };
395
- }
396
-
397
200
  export default interface $Model {
398
201
  permission: Permission;
399
202
  role: Role;
@@ -405,16 +208,6 @@ export default interface $Model {
405
208
  api_key: ApiKey;
406
209
  api_key__has__role: ApiKeyHasRole;
407
210
  api_key__has__permission: ApiKeyHasPermission;
408
- permission$sbvr__compiler: Permission;
409
- role$sbvr__compiler: Role;
410
- role__has__permission$sbvr__compiler: RoleHasPermission;
411
- actor$sbvr__compiler: Actor;
412
- user$sbvr__compiler: User;
413
- user__has__role$sbvr__compiler: UserHasRole;
414
- user__has__permission$sbvr__compiler: UserHasPermission;
415
- api_key$sbvr__compiler: ApiKey;
416
- api_key__has__role$sbvr__compiler: ApiKeyHasRole;
417
- api_key__has__permission$sbvr__compiler: ApiKeyHasPermission;
418
211
  // Synonyms
419
212
  user_role: UserHasRole;
420
213
  user_permission: UserHasPermission;