@jini-ai/platform 0.7.1 → 0.7.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.7.2
2
+
3
+ ### Patch Changes
4
+
5
+ - @jini-ai/core@0.7.2
6
+
1
7
  ## 0.7.1
2
8
 
3
9
  ### Patch Changes
@@ -0,0 +1,7 @@
1
+ /** Stable v1 AAD binding workspace, vendor, and credential identity. */
2
+ export declare function buildVendorCredentialAad(input: {
3
+ workspaceId: string;
4
+ vendorId: string;
5
+ id: string;
6
+ }): string;
7
+ //# sourceMappingURL=aad.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { formatAad } from "../aad.js";
2
+ const AAD_VERSION = "v1";
3
+ /** Stable v1 AAD binding workspace, vendor, and credential identity. */
4
+ export function buildVendorCredentialAad(input) {
5
+ return formatAad({ kind: "vendor-credential-set", version: AAD_VERSION, parts: [input.workspaceId, input.vendorId, input.id] });
6
+ }
7
+ //# sourceMappingURL=aad.js.map
@@ -0,0 +1,44 @@
1
+ import type { VendorCredentialSetRecord, VendorCredentialSetRepoPort } from "./types.js";
2
+ /**
3
+ * @file `VendorCredentialSetRepoPort`'s in-memory adapter — the ADR-006 rule-of-two test double,
4
+ * mirroring `../deployments/publish-credentials/repo.memory.ts`'s shape byte-for-byte with
5
+ * `providerId` swapped for `vendorId`. See that file's own header for the full reasoning (row
6
+ * keying, the enforced UNIQUE constraint matching better-sqlite3's own error wording, why no
7
+ * explicit lock is needed for the `isDefault` group invariant in a single-threaded JS process).
8
+ */
9
+ export declare class InMemoryVendorCredentialSetRepo implements VendorCredentialSetRepoPort {
10
+ constructor(_required: Record<string, never>, _optional?: Record<string, never>);
11
+ private readonly rows;
12
+ private static rowKey;
13
+ private assertLabelAvailable;
14
+ private clearOtherDefaults;
15
+ insert(record: VendorCredentialSetRecord, _optional?: Record<string, never>): Promise<void>;
16
+ update(record: VendorCredentialSetRecord, _optional?: Record<string, never>): Promise<void>;
17
+ findById(input: {
18
+ workspaceId: string;
19
+ id: string;
20
+ }, _optional?: Record<string, never>): Promise<VendorCredentialSetRecord | null>;
21
+ findDefaultByVendor(input: {
22
+ workspaceId: string;
23
+ vendorId: string;
24
+ }, _optional?: Record<string, never>): Promise<VendorCredentialSetRecord | null>;
25
+ listByVendor(input: {
26
+ workspaceId: string;
27
+ vendorId: string;
28
+ }, _optional?: Record<string, never>): Promise<VendorCredentialSetRecord[]>;
29
+ listByWorkspace(input: {
30
+ workspaceId: string;
31
+ }, _optional?: Record<string, never>): Promise<VendorCredentialSetRecord[]>;
32
+ delete(input: {
33
+ workspaceId: string;
34
+ id: string;
35
+ }, _optional?: Record<string, never>): Promise<void>;
36
+ /** Mirrors the SQLite adapter's targeted single-column write — see
37
+ * `VendorCredentialSetRepoPort.updateAccountLabel`'s own doc. No-op if the row vanished. */
38
+ updateAccountLabel(input: {
39
+ workspaceId: string;
40
+ id: string;
41
+ accountLabel: string;
42
+ }, _optional?: Record<string, never>): Promise<void>;
43
+ }
44
+ //# sourceMappingURL=repo.memory.d.ts.map
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @file `VendorCredentialSetRepoPort`'s in-memory adapter — the ADR-006 rule-of-two test double,
3
+ * mirroring `../deployments/publish-credentials/repo.memory.ts`'s shape byte-for-byte with
4
+ * `providerId` swapped for `vendorId`. See that file's own header for the full reasoning (row
5
+ * keying, the enforced UNIQUE constraint matching better-sqlite3's own error wording, why no
6
+ * explicit lock is needed for the `isDefault` group invariant in a single-threaded JS process).
7
+ */
8
+ export class InMemoryVendorCredentialSetRepo {
9
+ constructor(_required, _optional = {}) { }
10
+ rows = new Map();
11
+ static rowKey(workspaceId, id) {
12
+ return `${workspaceId}::${id}`;
13
+ }
14
+ assertLabelAvailable(workspaceId, vendorId, label, excludingId) {
15
+ for (const row of this.rows.values()) {
16
+ if (row.workspaceId !== workspaceId || row.vendorId !== vendorId || row.label !== label)
17
+ continue;
18
+ if (excludingId !== undefined && row.id === excludingId)
19
+ continue;
20
+ throw new Error(`UNIQUE constraint failed: vendor_credential_sets.workspace_id, vendor_credential_sets.vendor_id, vendor_credential_sets.label`);
21
+ }
22
+ }
23
+ clearOtherDefaults(workspaceId, vendorId, keepId) {
24
+ for (const [key, row] of this.rows) {
25
+ if (row.workspaceId !== workspaceId || row.vendorId !== vendorId || row.id === keepId || !row.isDefault)
26
+ continue;
27
+ this.rows.set(key, { ...row, isDefault: false });
28
+ }
29
+ }
30
+ async insert(record, _optional = {}) {
31
+ this.assertLabelAvailable(record.workspaceId, record.vendorId, record.label);
32
+ this.rows.set(InMemoryVendorCredentialSetRepo.rowKey(record.workspaceId, record.id), { ...record });
33
+ if (record.isDefault)
34
+ this.clearOtherDefaults(record.workspaceId, record.vendorId, record.id);
35
+ }
36
+ async update(record, _optional = {}) {
37
+ this.assertLabelAvailable(record.workspaceId, record.vendorId, record.label, record.id);
38
+ this.rows.set(InMemoryVendorCredentialSetRepo.rowKey(record.workspaceId, record.id), { ...record });
39
+ if (record.isDefault)
40
+ this.clearOtherDefaults(record.workspaceId, record.vendorId, record.id);
41
+ }
42
+ async findById(input, _optional = {}) {
43
+ return this.rows.get(InMemoryVendorCredentialSetRepo.rowKey(input.workspaceId, input.id)) ?? null;
44
+ }
45
+ async findDefaultByVendor(input, _optional = {}) {
46
+ for (const row of this.rows.values()) {
47
+ if (row.workspaceId === input.workspaceId && row.vendorId === input.vendorId && row.isDefault)
48
+ return row;
49
+ }
50
+ return null;
51
+ }
52
+ async listByVendor(input, _optional = {}) {
53
+ return [...this.rows.values()].filter((row) => row.workspaceId === input.workspaceId && row.vendorId === input.vendorId);
54
+ }
55
+ async listByWorkspace(input, _optional = {}) {
56
+ return [...this.rows.values()].filter((row) => row.workspaceId === input.workspaceId);
57
+ }
58
+ async delete(input, _optional = {}) {
59
+ const key = InMemoryVendorCredentialSetRepo.rowKey(input.workspaceId, input.id);
60
+ const removed = this.rows.get(key);
61
+ this.rows.delete(key);
62
+ if (!removed?.isDefault)
63
+ return;
64
+ const remaining = [...this.rows.values()].filter((row) => row.workspaceId === removed.workspaceId && row.vendorId === removed.vendorId);
65
+ if (remaining.length === 0)
66
+ return;
67
+ const promoted = remaining.reduce((latest, row) => (row.updatedAt > latest.updatedAt ? row : latest));
68
+ this.rows.set(InMemoryVendorCredentialSetRepo.rowKey(promoted.workspaceId, promoted.id), { ...promoted, isDefault: true });
69
+ }
70
+ /** Mirrors the SQLite adapter's targeted single-column write — see
71
+ * `VendorCredentialSetRepoPort.updateAccountLabel`'s own doc. No-op if the row vanished. */
72
+ async updateAccountLabel(input, _optional = {}) {
73
+ const key = InMemoryVendorCredentialSetRepo.rowKey(input.workspaceId, input.id);
74
+ const existing = this.rows.get(key);
75
+ if (!existing)
76
+ return;
77
+ this.rows.set(key, { ...existing, accountLabel: input.accountLabel });
78
+ }
79
+ }
80
+ //# sourceMappingURL=repo.memory.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/platform",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Generic OS/platform primitives: process exec and lifecycle, filesystem containment, HTTP readiness polling, toolchain discovery, blob storage, AWS signing, and an SSRF-safe asset cache.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -219,7 +219,7 @@
219
219
  "!dist/**/*.map"
220
220
  ],
221
221
  "dependencies": {
222
- "@jini-ai/core": "^0.7.1",
222
+ "@jini-ai/core": "^0.7.2",
223
223
  "undici": "^7.25.0"
224
224
  },
225
225
  "publishConfig": {