@ductape/cli 0.2.17 → 0.2.18
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/dist/lib/platform-api.js
CHANGED
|
@@ -53,10 +53,10 @@ export async function getProduct(ctx, opts) {
|
|
|
53
53
|
return unwrapOne(result);
|
|
54
54
|
}
|
|
55
55
|
if (opts.tag) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
// The integrations REST fetch-by-tag route rejects current CLI login tokens with HTTP 401.
|
|
57
|
+
// Product inventory is an administrative read, so route it through the authenticated CLI
|
|
58
|
+
// SDK proxy (x-access-token), not the publishable-key runtime MCP proxy.
|
|
59
|
+
const result = await proxy(ctx).execute('product', 'fetch', [opts.tag]);
|
|
60
60
|
return unwrapOne(result);
|
|
61
61
|
}
|
|
62
62
|
throw new Error('Provide --id <product_id> or --tag <product_tag>');
|
package/package.json
CHANGED
package/src/lib/platform-api.ts
CHANGED
|
@@ -69,10 +69,10 @@ export async function getProduct(
|
|
|
69
69
|
return unwrapOne(result);
|
|
70
70
|
}
|
|
71
71
|
if (opts.tag) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
// The integrations REST fetch-by-tag route rejects current CLI login tokens with HTTP 401.
|
|
73
|
+
// Product inventory is an administrative read, so route it through the authenticated CLI
|
|
74
|
+
// SDK proxy (x-access-token), not the publishable-key runtime MCP proxy.
|
|
75
|
+
const result = await proxy(ctx).execute<unknown>('product', 'fetch', [opts.tag]);
|
|
76
76
|
return unwrapOne(result);
|
|
77
77
|
}
|
|
78
78
|
throw new Error('Provide --id <product_id> or --tag <product_tag>');
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { describe, it } from 'node:test';
|
|
2
2
|
import assert from 'node:assert/strict';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
3
5
|
|
|
4
6
|
// Test unwrap helpers indirectly via exported patterns — use small inline copies for unit scope
|
|
5
7
|
function unwrapList<T>(result: unknown): T[] {
|
|
@@ -16,4 +18,16 @@ describe('platform-api helpers', () => {
|
|
|
16
18
|
assert.deepEqual(unwrapList({ data: [{ tag: 'b' }] }), [{ tag: 'b' }]);
|
|
17
19
|
assert.deepEqual(unwrapList({}), []);
|
|
18
20
|
});
|
|
21
|
+
|
|
22
|
+
it('routes product fetch-by-tag through the authenticated CLI SDK proxy', () => {
|
|
23
|
+
const source = readFileSync(
|
|
24
|
+
fileURLToPath(new URL('../src/lib/platform-api.ts', import.meta.url)),
|
|
25
|
+
'utf8',
|
|
26
|
+
);
|
|
27
|
+
assert.match(source, /proxy\(ctx\)\.execute<unknown>\('product', 'fetch', \[opts\.tag\]\)/);
|
|
28
|
+
assert.doesNotMatch(
|
|
29
|
+
source,
|
|
30
|
+
/getPath<unknown>\(`\/integrations\/v1\/fetch\/tag`/,
|
|
31
|
+
);
|
|
32
|
+
});
|
|
19
33
|
});
|