@platformatic/watt-extra 1.0.0 → 1.0.1-alpha.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/watt-extra",
3
- "version": "1.0.0",
3
+ "version": "1.0.1-alpha.0",
4
4
  "description": "The Platformatic runtime manager",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -9,7 +9,13 @@
9
9
  "start": "node index.js"
10
10
  },
11
11
  "bin": {
12
- "watt-extra": "./cli.js"
12
+ "watt-extra": "cli.js"
13
+ },
14
+ "author": "Platformatic Team",
15
+ "license": "Apache-2.0",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/platformatic/watt-extra.git"
13
19
  },
14
20
  "devDependencies": {
15
21
  "@fastify/websocket": "^11.1.0",
@@ -16,6 +16,7 @@ async function compliancy (app, _opts) {
16
16
 
17
17
  const runtime = app.watt.runtime
18
18
  const applicationId = app.instanceConfig?.applicationId
19
+ const instanceId = app.instanceId
19
20
  const appDir = app.env.PLT_APP_DIR
20
21
 
21
22
  const { default: build, setDefaultHeaders } = await import('../clients/compliance/compliance.mjs')
@@ -38,8 +39,11 @@ async function compliancy (app, _opts) {
38
39
 
39
40
  {
40
41
  const res = await compliancyClient.postMetadata({
41
- applicationId,
42
- data: compliancyMetadata
42
+ body: {
43
+ applicationId,
44
+ podId: instanceId,
45
+ data: compliancyMetadata
46
+ }
43
47
  })
44
48
 
45
49
  if (res.statusCode !== 200 && res.statusCode !== 201) {
@@ -51,7 +55,9 @@ async function compliancy (app, _opts) {
51
55
  }
52
56
 
53
57
  {
54
- const res = await compliancyClient.postCompliance({ applicationId })
58
+ const res = await compliancyClient.postCompliance({
59
+ body: { applicationId, podId: instanceId }
60
+ })
55
61
  if (res.statusCode !== 200) {
56
62
  app.log.error(res, 'Failed to get compliance status')
57
63
  throw new CompliancyStatusError()
package/plugins/init.js CHANGED
@@ -9,7 +9,10 @@ async function initPlugin (app) {
9
9
  // every time, because the token might be expired
10
10
  // And we cannot set the global dispatcher because it's shared with the runtime main thread.
11
11
  setDefaultHeaders(await app.getAuthorizationHeader())
12
- const request = { podId }
12
+ const request = {
13
+ podId,
14
+ apiVersion: 'v3'
15
+ }
13
16
  if (applicationName) {
14
17
  request.applicationName = applicationName
15
18
  }
@@ -30,8 +30,8 @@ test('should retrieve and send compliancy metadata', async (t) => {
30
30
 
31
31
  const icc = await startICC(t, {
32
32
  applicationId,
33
- saveComplianceMetadata: async (applicationId, data) => {
34
- receivedMetadata.push({ applicationId, data })
33
+ saveComplianceMetadata: async (metadata) => {
34
+ receivedMetadata.push(metadata)
35
35
  },
36
36
  getComplianceReport: async () => {
37
37
  return { compliant: true }
@@ -56,6 +56,7 @@ test('should retrieve and send compliancy metadata', async (t) => {
56
56
 
57
57
  const [metadata] = receivedMetadata
58
58
  assert.strictEqual(metadata.applicationId, applicationId)
59
+ assert.deepStrictEqual(metadata.podId, app.instanceId)
59
60
  assert.deepStrictEqual(metadata.data, {
60
61
  npmDependencies: {
61
62
  runtime: {
package/test/helper.js CHANGED
@@ -118,11 +118,6 @@ async function startICC (t, opts = {}) {
118
118
  }
119
119
  })
120
120
 
121
- icc.post('/applications/:id/metadata', async (req) => {
122
- const { applicationId, data } = req.body
123
- return opts.saveComplianceMetadata?.(applicationId, data)
124
- })
125
-
126
121
  icc.post('/pods/:id/instance/state', async (req) => {
127
122
  const instanceId = req.params.id
128
123
  const state = req.body
@@ -135,13 +130,11 @@ async function startICC (t, opts = {}) {
135
130
  // Compliance
136
131
  await icc.register(async (icc) => {
137
132
  icc.post('/metadata', async (req) => {
138
- const { applicationId, data } = req.body
139
- return opts.saveComplianceMetadata?.(applicationId, data)
133
+ return opts.saveComplianceMetadata?.(req.body)
140
134
  })
141
135
 
142
136
  icc.post('/compliance', async (req) => {
143
- const { applicationId } = req.body
144
- return opts.getComplianceReport?.(applicationId)
137
+ return opts.getComplianceReport?.(req.body)
145
138
  })
146
139
  }, { prefix: '/compliance' })
147
140
 
package/test/init.test.js CHANGED
@@ -191,6 +191,7 @@ test('init plugin sends correct request structure when PLT_APP_NAME provided', a
191
191
  equal(capturedRequest.params.podId, instanceId)
192
192
  equal(capturedRequest.body.applicationName, applicationName)
193
193
  equal(capturedRequest.body.podId, instanceId)
194
+ equal(capturedRequest.body.apiVersion, 'v3')
194
195
  })
195
196
 
196
197
  test('init plugin sends request without applicationName when not provided', async (t) => {
@@ -237,6 +238,7 @@ test('init plugin sends request without applicationName when not provided', asyn
237
238
  equal(capturedRequest.params.podId, instanceId)
238
239
  equal(capturedRequest.body.podId, instanceId)
239
240
  equal(capturedRequest.body.applicationName, undefined)
241
+ equal(capturedRequest.body.apiVersion, 'v3')
240
242
 
241
243
  // But app should have the name from ICC response
242
244
  equal(app.applicationName, applicationName)