@api-client/core 0.19.22 → 0.19.24

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 (98) hide show
  1. package/build/src/browser.d.ts +3 -0
  2. package/build/src/browser.d.ts.map +1 -1
  3. package/build/src/browser.js +2 -0
  4. package/build/src/browser.js.map +1 -1
  5. package/build/src/index.d.ts +3 -0
  6. package/build/src/index.d.ts.map +1 -1
  7. package/build/src/index.js +2 -0
  8. package/build/src/index.js.map +1 -1
  9. package/build/src/modeling/ApiModel.d.ts.map +1 -1
  10. package/build/src/modeling/ApiModel.js +37 -13
  11. package/build/src/modeling/ApiModel.js.map +1 -1
  12. package/build/src/modeling/ExposedEntity.d.ts.map +1 -1
  13. package/build/src/modeling/ExposedEntity.js +54 -15
  14. package/build/src/modeling/ExposedEntity.js.map +1 -1
  15. package/build/src/modeling/actions/Action.js +2 -2
  16. package/build/src/modeling/actions/Action.js.map +1 -1
  17. package/build/src/modeling/rules/AccessRule.d.ts +5 -1
  18. package/build/src/modeling/rules/AccessRule.d.ts.map +1 -1
  19. package/build/src/modeling/rules/AccessRule.js +4 -1
  20. package/build/src/modeling/rules/AccessRule.js.map +1 -1
  21. package/build/src/modeling/rules/AllowAuthenticated.d.ts +4 -1
  22. package/build/src/modeling/rules/AllowAuthenticated.d.ts.map +1 -1
  23. package/build/src/modeling/rules/AllowAuthenticated.js +2 -2
  24. package/build/src/modeling/rules/AllowAuthenticated.js.map +1 -1
  25. package/build/src/modeling/rules/AllowPublic.d.ts +4 -1
  26. package/build/src/modeling/rules/AllowPublic.d.ts.map +1 -1
  27. package/build/src/modeling/rules/AllowPublic.js +2 -2
  28. package/build/src/modeling/rules/AllowPublic.js.map +1 -1
  29. package/build/src/modeling/rules/MatchEmailDomain.d.ts +4 -1
  30. package/build/src/modeling/rules/MatchEmailDomain.d.ts.map +1 -1
  31. package/build/src/modeling/rules/MatchEmailDomain.js +2 -2
  32. package/build/src/modeling/rules/MatchEmailDomain.js.map +1 -1
  33. package/build/src/modeling/rules/MatchResourceOwner.d.ts +4 -1
  34. package/build/src/modeling/rules/MatchResourceOwner.d.ts.map +1 -1
  35. package/build/src/modeling/rules/MatchResourceOwner.js +2 -2
  36. package/build/src/modeling/rules/MatchResourceOwner.js.map +1 -1
  37. package/build/src/modeling/rules/MatchUserProperty.d.ts +4 -1
  38. package/build/src/modeling/rules/MatchUserProperty.d.ts.map +1 -1
  39. package/build/src/modeling/rules/MatchUserProperty.js +2 -2
  40. package/build/src/modeling/rules/MatchUserProperty.js.map +1 -1
  41. package/build/src/modeling/rules/MatchUserRole.d.ts +4 -1
  42. package/build/src/modeling/rules/MatchUserRole.d.ts.map +1 -1
  43. package/build/src/modeling/rules/MatchUserRole.js +2 -2
  44. package/build/src/modeling/rules/MatchUserRole.js.map +1 -1
  45. package/build/src/modeling/rules/index.d.ts +4 -1
  46. package/build/src/modeling/rules/index.d.ts.map +1 -1
  47. package/build/src/modeling/rules/index.js +7 -7
  48. package/build/src/modeling/rules/index.js.map +1 -1
  49. package/build/src/models/store/CustomDomain.d.ts +50 -0
  50. package/build/src/models/store/CustomDomain.d.ts.map +1 -0
  51. package/build/src/models/store/CustomDomain.js +79 -0
  52. package/build/src/models/store/CustomDomain.js.map +1 -0
  53. package/build/src/models/store/Deployment.d.ts +81 -0
  54. package/build/src/models/store/Deployment.d.ts.map +1 -0
  55. package/build/src/models/store/Deployment.js +124 -0
  56. package/build/src/models/store/Deployment.js.map +1 -0
  57. package/build/src/models/store/DeploymentCustomDomain.d.ts +52 -0
  58. package/build/src/models/store/DeploymentCustomDomain.d.ts.map +1 -0
  59. package/build/src/models/store/DeploymentCustomDomain.js +84 -0
  60. package/build/src/models/store/DeploymentCustomDomain.js.map +1 -0
  61. package/build/tsconfig.tsbuildinfo +1 -1
  62. package/package.json +1 -1
  63. package/src/modeling/ApiModel.ts +37 -13
  64. package/src/modeling/ExposedEntity.ts +62 -16
  65. package/src/modeling/actions/Action.ts +2 -2
  66. package/src/modeling/rules/AccessRule.ts +8 -1
  67. package/src/modeling/rules/AllowAuthenticated.ts +5 -2
  68. package/src/modeling/rules/AllowPublic.ts +5 -2
  69. package/src/modeling/rules/MatchEmailDomain.ts +5 -2
  70. package/src/modeling/rules/MatchResourceOwner.ts +5 -2
  71. package/src/modeling/rules/MatchUserProperty.ts +5 -2
  72. package/src/modeling/rules/MatchUserRole.ts +5 -2
  73. package/src/models/store/CustomDomain.ts +119 -0
  74. package/src/models/store/Deployment.ts +173 -0
  75. package/src/models/store/DeploymentCustomDomain.ts +120 -0
  76. package/tests/unit/modeling/actions/Action.spec.ts +13 -10
  77. package/tests/unit/modeling/actions/CreateAction.spec.ts +7 -6
  78. package/tests/unit/modeling/actions/DeleteAction.spec.ts +7 -6
  79. package/tests/unit/modeling/actions/ListAction.spec.ts +5 -4
  80. package/tests/unit/modeling/actions/ReadAction.spec.ts +9 -8
  81. package/tests/unit/modeling/actions/SearchAction.spec.ts +5 -4
  82. package/tests/unit/modeling/actions/UpdateAction.spec.ts +7 -6
  83. package/tests/unit/modeling/actions/helpers.ts +7 -0
  84. package/tests/unit/modeling/api_model.spec.ts +3 -1
  85. package/tests/unit/modeling/api_model_expose_entity.spec.ts +5 -17
  86. package/tests/unit/modeling/exposed_entity.spec.ts +6 -2
  87. package/tests/unit/modeling/exposed_entity_actions.spec.ts +0 -4
  88. package/tests/unit/modeling/rules/AccessRule.spec.ts +6 -5
  89. package/tests/unit/modeling/rules/AllowAuthenticated.spec.ts +4 -3
  90. package/tests/unit/modeling/rules/AllowPublic.spec.ts +4 -3
  91. package/tests/unit/modeling/rules/MatchEmailDomain.spec.ts +6 -5
  92. package/tests/unit/modeling/rules/MatchResourceOwner.spec.ts +7 -6
  93. package/tests/unit/modeling/rules/MatchUserProperty.spec.ts +6 -5
  94. package/tests/unit/modeling/rules/MatchUserRole.spec.ts +6 -5
  95. package/tests/unit/modeling/rules/restoring_rules.spec.ts +19 -21
  96. package/tests/unit/models/store/CustomDomain.spec.ts +111 -0
  97. package/tests/unit/models/store/Deployment.spec.ts +134 -0
  98. package/tests/unit/models/store/DeploymentCustomDomain.spec.ts +122 -0
@@ -0,0 +1,134 @@
1
+ import { test } from '@japa/runner'
2
+ import { Deployment, DeploymentStatus } from '../../../../src/models/store/Deployment.js'
3
+ import type { DeploymentSchema } from '../../../../src/models/store/Deployment.js'
4
+
5
+ test.group('Deployment model', () => {
6
+ test('createSchema() returns default values', ({ assert }) => {
7
+ const result = Deployment.createSchema()
8
+ assert.isString(result.id)
9
+ assert.equal(result.orgId, '')
10
+ assert.equal(result.apiId, '')
11
+ assert.equal(result.deploymentVersion, 'v0')
12
+ assert.equal(result.apiModelVersion, '0.0.0')
13
+ assert.equal(result.status, DeploymentStatus.Pending)
14
+ assert.isUndefined(result.stagingPath)
15
+ assert.isUndefined(result.mongoModelId)
16
+ assert.isNumber(result.createdAt)
17
+ assert.isNumber(result.updatedAt)
18
+ })
19
+
20
+ test('createSchema(init) assigns values', ({ assert }) => {
21
+ const init: Partial<DeploymentSchema> = {
22
+ id: 'test-id',
23
+ orgId: 'org-1',
24
+ apiId: 'api-1',
25
+ deploymentVersion: 'v1',
26
+ apiModelVersion: '1.0.0',
27
+ status: DeploymentStatus.Active,
28
+ stagingPath: '/stage',
29
+ mongoModelId: 'mongo-1',
30
+ createdAt: 12345,
31
+ updatedAt: 67890,
32
+ }
33
+ const result = Deployment.createSchema(init)
34
+ assert.equal(result.id, 'test-id')
35
+ assert.equal(result.orgId, 'org-1')
36
+ assert.equal(result.apiId, 'api-1')
37
+ assert.equal(result.deploymentVersion, 'v1')
38
+ assert.equal(result.apiModelVersion, '1.0.0')
39
+ assert.equal(result.status, DeploymentStatus.Active)
40
+ assert.equal(result.stagingPath, '/stage')
41
+ assert.equal(result.mongoModelId, 'mongo-1')
42
+ assert.equal(result.createdAt, 12345)
43
+ assert.equal(result.updatedAt, 67890)
44
+ })
45
+
46
+ test('constructor() initializes with default values', ({ assert }) => {
47
+ const deployment = new Deployment()
48
+ assert.isString(deployment.id)
49
+ assert.equal(deployment.orgId, '')
50
+ assert.equal(deployment.apiId, '')
51
+ assert.equal(deployment.deploymentVersion, 'v0')
52
+ assert.equal(deployment.apiModelVersion, '0.0.0')
53
+ assert.equal(deployment.status, DeploymentStatus.Pending)
54
+ assert.isUndefined(deployment.stagingPath)
55
+ assert.isUndefined(deployment.mongoModelId)
56
+ assert.isNumber(deployment.createdAt)
57
+ assert.isNumber(deployment.updatedAt)
58
+ })
59
+
60
+ test('constructor(init) assigns values', ({ assert }) => {
61
+ const init: Partial<DeploymentSchema> = {
62
+ orgId: 'org-1',
63
+ apiId: 'api-1',
64
+ stagingPath: '/stage',
65
+ }
66
+ const deployment = new Deployment(init)
67
+ assert.equal(deployment.orgId, 'org-1')
68
+ assert.equal(deployment.apiId, 'api-1')
69
+ assert.equal(deployment.stagingPath, '/stage')
70
+ })
71
+
72
+ test('toJSON() returns the schema representation', ({ assert }) => {
73
+ const init: Partial<DeploymentSchema> = {
74
+ id: 'test-id',
75
+ orgId: 'org-1',
76
+ apiId: 'api-1',
77
+ deploymentVersion: 'v1',
78
+ apiModelVersion: '1.0.0',
79
+ status: DeploymentStatus.Active,
80
+ stagingPath: '/stage',
81
+ mongoModelId: 'mongo-1',
82
+ createdAt: 12345,
83
+ updatedAt: 67890,
84
+ }
85
+ const deployment = new Deployment(init)
86
+ const result = deployment.toJSON()
87
+ assert.deepEqual(result, {
88
+ id: 'test-id',
89
+ orgId: 'org-1',
90
+ apiId: 'api-1',
91
+ deploymentVersion: 'v1',
92
+ apiModelVersion: '1.0.0',
93
+ status: DeploymentStatus.Active,
94
+ stagingPath: '/stage',
95
+ mongoModelId: 'mongo-1',
96
+ createdAt: 12345,
97
+ updatedAt: 67890,
98
+ })
99
+ })
100
+
101
+ test('validate() returns errors for empty fields', ({ assert }) => {
102
+ const deployment = new Deployment({
103
+ orgId: '',
104
+ apiId: '',
105
+ })
106
+ deployment.deploymentVersion = ''
107
+ deployment.apiModelVersion = ''
108
+ const errors = deployment.validate()
109
+ assert.lengthOf(errors, 4)
110
+ assert.deepEqual(errors[0], { field: 'orgId', message: 'Org ID must not be empty', rule: 'notEmpty' })
111
+ assert.deepEqual(errors[1], { field: 'apiId', message: 'API ID must not be empty', rule: 'notEmpty' })
112
+ assert.deepEqual(errors[2], {
113
+ field: 'deploymentVersion',
114
+ message: 'Deployment version must not be empty',
115
+ rule: 'notEmpty',
116
+ })
117
+ assert.deepEqual(errors[3], {
118
+ field: 'apiModelVersion',
119
+ message: 'API model version must not be empty',
120
+ rule: 'notEmpty',
121
+ })
122
+ })
123
+
124
+ test('validate() returns no errors for valid model', ({ assert }) => {
125
+ const deployment = new Deployment({
126
+ orgId: 'org-1',
127
+ apiId: 'api-1',
128
+ deploymentVersion: 'v1',
129
+ apiModelVersion: '1.0.0',
130
+ })
131
+ const errors = deployment.validate()
132
+ assert.lengthOf(errors, 0)
133
+ })
134
+ })
@@ -0,0 +1,122 @@
1
+ import { test } from '@japa/runner'
2
+ import { DeploymentCustomDomainModel, SslStatus } from '../../../../src/models/store/DeploymentCustomDomain.js'
3
+ import type { DeploymentCustomDomainSchema } from '../../../../src/models/store/DeploymentCustomDomain.js'
4
+
5
+ test.group('DeploymentCustomDomain model', () => {
6
+ test('createSchema() returns default values', ({ assert }) => {
7
+ const result = DeploymentCustomDomainModel.createSchema()
8
+ assert.isString(result.id)
9
+ assert.equal(result.deploymentId, '')
10
+ assert.equal(result.customDomainId, '')
11
+ assert.equal(result.basePath, '/')
12
+ assert.equal(result.sslStatus, SslStatus.PendingDns)
13
+ assert.isNumber(result.createdAt)
14
+ assert.isNumber(result.updatedAt)
15
+ })
16
+
17
+ test('createSchema(init) assigns values', ({ assert }) => {
18
+ const init: Partial<DeploymentCustomDomainSchema> = {
19
+ id: 'test-id',
20
+ deploymentId: 'dep-1',
21
+ customDomainId: 'dom-1',
22
+ basePath: '/api',
23
+ sslStatus: SslStatus.Active,
24
+ createdAt: 12345,
25
+ updatedAt: 67890,
26
+ }
27
+ const result = DeploymentCustomDomainModel.createSchema(init)
28
+ assert.equal(result.id, 'test-id')
29
+ assert.equal(result.deploymentId, 'dep-1')
30
+ assert.equal(result.customDomainId, 'dom-1')
31
+ assert.equal(result.basePath, '/api')
32
+ assert.equal(result.sslStatus, SslStatus.Active)
33
+ assert.equal(result.createdAt, 12345)
34
+ assert.equal(result.updatedAt, 67890)
35
+ })
36
+
37
+ test('constructor() initializes with default values', ({ assert }) => {
38
+ const model = new DeploymentCustomDomainModel()
39
+ assert.isString(model.id)
40
+ assert.equal(model.deploymentId, '')
41
+ assert.equal(model.customDomainId, '')
42
+ assert.equal(model.basePath, '/')
43
+ assert.equal(model.sslStatus, SslStatus.PendingDns)
44
+ assert.isNumber(model.createdAt)
45
+ assert.isNumber(model.updatedAt)
46
+ })
47
+
48
+ test('constructor(init) assigns values', ({ assert }) => {
49
+ const init: Partial<DeploymentCustomDomainSchema> = {
50
+ deploymentId: 'dep-1',
51
+ customDomainId: 'dom-1',
52
+ basePath: '/api',
53
+ }
54
+ const model = new DeploymentCustomDomainModel(init)
55
+ assert.equal(model.deploymentId, 'dep-1')
56
+ assert.equal(model.customDomainId, 'dom-1')
57
+ assert.equal(model.basePath, '/api')
58
+ })
59
+
60
+ test('toJSON() returns the schema representation', ({ assert }) => {
61
+ const init: Partial<DeploymentCustomDomainSchema> = {
62
+ id: 'test-id',
63
+ deploymentId: 'dep-1',
64
+ customDomainId: 'dom-1',
65
+ basePath: '/api',
66
+ sslStatus: SslStatus.Active,
67
+ createdAt: 12345,
68
+ updatedAt: 67890,
69
+ }
70
+ const model = new DeploymentCustomDomainModel(init)
71
+ const result = model.toJSON()
72
+ assert.deepEqual(result, {
73
+ id: 'test-id',
74
+ deploymentId: 'dep-1',
75
+ customDomainId: 'dom-1',
76
+ basePath: '/api',
77
+ sslStatus: SslStatus.Active,
78
+ createdAt: 12345,
79
+ updatedAt: 67890,
80
+ })
81
+ })
82
+
83
+ test('validate() returns errors for empty and invalid fields', ({ assert }) => {
84
+ const model = new DeploymentCustomDomainModel({
85
+ basePath: '',
86
+ deploymentId: '',
87
+ customDomainId: '',
88
+ })
89
+ let errors = model.validate()
90
+ assert.lengthOf(errors, 3)
91
+ assert.deepEqual(errors[0], { field: 'basePath', message: 'Base path must not be empty', rule: 'notEmpty' })
92
+ assert.deepEqual(errors[1], { field: 'deploymentId', message: 'Deployment ID must not be empty', rule: 'notEmpty' })
93
+ assert.deepEqual(errors[2], {
94
+ field: 'customDomainId',
95
+ message: 'Custom domain ID must not be empty',
96
+ rule: 'notEmpty',
97
+ })
98
+
99
+ const modelInvalidPath = new DeploymentCustomDomainModel({
100
+ basePath: 'api/path',
101
+ deploymentId: 'dep-1',
102
+ customDomainId: 'dom-1',
103
+ })
104
+ errors = modelInvalidPath.validate()
105
+ assert.lengthOf(errors, 1)
106
+ assert.deepEqual(errors[0], {
107
+ field: 'basePath',
108
+ message: 'Base path must start with a slash',
109
+ rule: 'startsWithSlash',
110
+ })
111
+ })
112
+
113
+ test('validate() returns no errors for valid model', ({ assert }) => {
114
+ const model = new DeploymentCustomDomainModel({
115
+ deploymentId: 'dep-1',
116
+ customDomainId: 'dom-1',
117
+ basePath: '/api',
118
+ })
119
+ const errors = model.validate()
120
+ assert.lengthOf(errors, 0)
121
+ })
122
+ })