anbaric-impl-cloud 1.7.0 → 1.8.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": "anbaric-impl-cloud",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Public client library for the Anbaric Cloud hosting API, providing JobPersistence and Queue implementations backed by the cloud service",
5
5
  "license": "MIT",
6
6
  "author": "chris@anbaric.ai",
@@ -11,7 +11,7 @@
11
11
  "test": "vitest run"
12
12
  },
13
13
  "dependencies": {
14
- "anbaric-tsapi": "^1.7.0"
14
+ "anbaric-tsapi": "^1.8.0"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@types/node": "^26.2.0",
@@ -1,4 +1,4 @@
1
- import {Actor, AuditChange, Auditor} from "anbaric-tsapi";
1
+ import {Actor, AuditInteraction, Auditor} from "anbaric-tsapi";
2
2
  import {CloudApiClient} from "./CloudApiClient";
3
3
 
4
4
  class CloudAuditor implements Auditor {
@@ -9,14 +9,15 @@ class CloudAuditor implements Auditor {
9
9
  this.client = new CloudApiClient(baseUrl);
10
10
  }
11
11
 
12
- async audit(jobId : string, actor : Actor, change : AuditChange,
13
- changeDescription : string, details : any) : Promise<void> {
12
+ async audit(resourceType : string, resourceId : string, actor : Actor, interaction : AuditInteraction[],
13
+ description : string, details : any) : Promise<void> {
14
14
  await this.client.request("POST", "/audits", {
15
- jobId,
15
+ resourceType,
16
+ resourceId,
16
17
  actorId: actor.id,
17
18
  actorType: actor.type,
18
- change,
19
- description: changeDescription,
19
+ interaction,
20
+ description,
20
21
  details: details ?? null,
21
22
  });
22
23
  }
@@ -1,36 +1,33 @@
1
- import {Job, JobPersistence, SerializedJob, deserializeJob, serializeJob} from "anbaric-tsapi";
1
+ import {Auditor, Job, JobPersistence, NoOpAuditor, SerializedJob, deserializeJob, serializeJob} from "anbaric-tsapi";
2
2
  import {CloudApiClient} from "./CloudApiClient";
3
3
 
4
- class CloudJobPersistence implements JobPersistence {
4
+ class CloudJobPersistence extends JobPersistence {
5
5
 
6
6
  private client : CloudApiClient;
7
7
 
8
- constructor(baseUrl : string = CloudApiClient.defaultBaseUrl()) {
8
+ constructor(baseUrl : string = CloudApiClient.defaultBaseUrl(), auditor : Auditor = new NoOpAuditor()) {
9
+ super(auditor);
9
10
  this.client = new CloudApiClient(baseUrl);
10
11
  }
11
12
 
12
- async save(job : Job) : Promise<void> {
13
+ protected async saveInternal(job : Job) : Promise<void> {
13
14
  await this.client.request("PUT", `/jobs/${encodeURIComponent(job.id)}`, serializeJob(job));
14
15
  }
15
16
 
16
- async retrieve(id : string) : Promise<Job> {
17
+ protected async retrieveInternal(id : string) : Promise<Job> {
17
18
  const serialized = await this.client.request("GET", `/jobs/${encodeURIComponent(id)}`) as SerializedJob;
18
19
  return deserializeJob(serialized);
19
20
  }
20
21
 
21
- async delete(id : string) : Promise<void> {
22
+ protected async deleteInternal(id : string) : Promise<void> {
22
23
  await this.client.request("DELETE", `/jobs/${encodeURIComponent(id)}`);
23
24
  }
24
25
 
25
- async list(pageSize : number = 100, page : number = 0) : Promise<Array<Job>> {
26
+ protected async listInternal(pageSize : number = 100, page : number = 0) : Promise<Array<Job>> {
26
27
  const serialized = await this.client.request("GET", `/jobs?pageSize=${pageSize}&page=${page}`) as Array<SerializedJob>;
27
28
  return serialized.map(deserializeJob);
28
29
  }
29
30
 
30
- async updateProperties(id : string, properties : Map<string, any>) : Promise<void> {
31
- await this.client.request("PATCH", `/jobs/${encodeURIComponent(id)}/properties`, Object.fromEntries(properties));
32
- }
33
-
34
31
  }
35
32
 
36
33
  export { CloudJobPersistence }
@@ -1,16 +1,19 @@
1
- import {JsonSchema, JsonStore, validateDocument} from "anbaric-tsapi";
1
+ import {Auditor, JsonSchema, JsonStore, NoOpAuditor, validateDocument} from "anbaric-tsapi";
2
2
  import {CloudApiClient} from "./CloudApiClient";
3
3
 
4
- class CloudJsonStore implements JsonStore {
4
+ class CloudJsonStore extends JsonStore {
5
5
 
6
6
  private client : CloudApiClient;
7
+ private schema? : JsonSchema;
7
8
 
8
- constructor(private collection : string, private schema? : JsonSchema,
9
- baseUrl : string = CloudApiClient.defaultBaseUrl()) {
9
+ constructor(collection : string, schema? : JsonSchema,
10
+ baseUrl : string = CloudApiClient.defaultBaseUrl(), auditor : Auditor = new NoOpAuditor()) {
11
+ super(auditor, collection);
12
+ this.schema = schema;
10
13
  this.client = new CloudApiClient(baseUrl);
11
14
  }
12
15
 
13
- async save(id : string, document : any) : Promise<void> {
16
+ protected async saveInternal(id : string, document : any) : Promise<void> {
14
17
  if (this.schema) {
15
18
  const violations = validateDocument(document, this.schema);
16
19
  if (violations.length > 0) {
@@ -20,15 +23,15 @@ class CloudJsonStore implements JsonStore {
20
23
  await this.client.request("PUT", this.documentPath(id), document);
21
24
  }
22
25
 
23
- async retrieve(id : string) : Promise<any> {
26
+ protected async retrieveInternal(id : string) : Promise<any> {
24
27
  return this.client.request("GET", this.documentPath(id));
25
28
  }
26
29
 
27
- async delete(id : string) : Promise<void> {
30
+ protected async deleteInternal(id : string) : Promise<void> {
28
31
  await this.client.request("DELETE", this.documentPath(id));
29
32
  }
30
33
 
31
- async list(pageSize : number = 100, page : number = 0) : Promise<Array<any>> {
34
+ protected async listInternal(pageSize : number = 100, page : number = 0) : Promise<Array<any>> {
32
35
  return this.client.request("GET", `/documents/${encodeURIComponent(this.collection)}?pageSize=${pageSize}&page=${page}`);
33
36
  }
34
37
 
@@ -1,28 +1,29 @@
1
- import {SecretStore} from "anbaric-tsapi";
1
+ import {Auditor, NoOpAuditor, SecretStore} from "anbaric-tsapi";
2
2
  import {CloudApiClient} from "./CloudApiClient";
3
3
 
4
- class CloudSecretStore implements SecretStore {
4
+ class CloudSecretStore extends SecretStore {
5
5
 
6
6
  private client : CloudApiClient;
7
7
 
8
- constructor(baseUrl : string = CloudApiClient.defaultBaseUrl()) {
8
+ constructor(baseUrl : string = CloudApiClient.defaultBaseUrl(), auditor : Auditor = new NoOpAuditor()) {
9
+ super(auditor);
9
10
  this.client = new CloudApiClient(baseUrl);
10
11
  }
11
12
 
12
- async save(name : string, value : string) : Promise<void> {
13
+ protected async saveInternal(name : string, value : string) : Promise<void> {
13
14
  await this.client.request("PUT", this.secretPath(name), { value });
14
15
  }
15
16
 
16
- async retrieve(name : string) : Promise<string> {
17
+ protected async retrieveInternal(name : string) : Promise<string> {
17
18
  const secret = await this.client.request("GET", this.secretPath(name)) as { value : string };
18
19
  return secret.value;
19
20
  }
20
21
 
21
- async delete(name : string) : Promise<void> {
22
+ protected async deleteInternal(name : string) : Promise<void> {
22
23
  await this.client.request("DELETE", this.secretPath(name));
23
24
  }
24
25
 
25
- async list() : Promise<Array<string>> {
26
+ protected async listInternal() : Promise<Array<string>> {
26
27
  return this.client.request("GET", "/secrets");
27
28
  }
28
29